fix(tvix/eval): builtins.match: propagate catchables

Change-Id: I14c9e625c91369e10d0c00380dca992811ae9059
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10346
Reviewed-by: sterni <sternenseemann@systemli.org>
Autosubmit: Adam Joseph <adam@westernsemico.com>
Tested-by: BuildkiteCI
This commit is contained in:
Adam Joseph 2023-12-12 20:49:57 -08:00 committed by tazjin
parent 11e35a77a6
commit 2af8174e2e
3 changed files with 12 additions and 2 deletions

View file

@ -766,8 +766,16 @@ mod pure_builtins {
#[builtin("match")]
async fn builtin_match(co: GenCo, regex: Value, str: Value) -> Result<Value, ErrorKind> {
let s = str.to_str()?;
let re = regex.to_str()?;
let s = str;
if s.is_catchable() {
return Ok(s);
}
let s = s.to_str()?;
let re = regex;
if re.is_catchable() {
return Ok(re);
}
let re = re.to_str()?;
let re: Regex = Regex::new(&format!("^{}$", re.as_str())).unwrap();
match re.captures(&s) {
Some(caps) => Ok(Value::List(

View file

@ -0,0 +1 @@
(builtins.tryEval (builtins.match (throw "foo") ".*")).success