Ignore errors from builtin functions in non strict mode (#154)

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-02-22 15:46:51 -08:00
committed by GitHub
parent 22047287b4
commit 10f2caf0c0
2 changed files with 25 additions and 1 deletions

View File

@@ -2055,7 +2055,12 @@ impl Interpreter {
}
}
let v = builtin.0(span, params, &args[..], self.strict_builtin_errors)?;
let v = match builtin.0(span, params, &args[..], self.strict_builtin_errors) {
Ok(v) => v,
// Ignore errors if we are not evaluating in strict mode.
Err(_) if !self.strict_builtin_errors => return Ok(Value::Undefined),
Err(e) => Err(e)?,
};
// Handle trace function.
// TODO: with modifier.

View File

@@ -0,0 +1,19 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cases:
- note: builtin error gobbled up in non strict mode
modules:
- |
package test
a = to_number("abc")
query: data.test
want_result: {}
strict: false
- note: builtin error in strict mode
modules:
- |
package test
a = to_number("abc")
query: data.test
error: "could not parse string as number"