mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Propagate Undefined in object expressions (#171)
Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
976c04be8a
commit
863601c2d5
@@ -1905,7 +1905,13 @@ impl Interpreter {
|
||||
// ( scalar | ref | var ) ":" term, the OPA
|
||||
// implementation is more like expr ":" expr
|
||||
let key = self.eval_expr(key)?;
|
||||
if key == Value::Undefined {
|
||||
return Ok(Value::Undefined);
|
||||
}
|
||||
let value = self.eval_expr(value)?;
|
||||
if value == Value::Undefined {
|
||||
return Ok(Value::Undefined);
|
||||
}
|
||||
object.insert(key, value);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,3 +17,38 @@
|
||||
a = to_number("abc")
|
||||
query: data.test
|
||||
error: "could not parse string as number"
|
||||
|
||||
- note: count of null error gobbled up in non strict mode
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
import rego.v1
|
||||
|
||||
foo := input.a
|
||||
|
||||
some_id := {
|
||||
"count_value": count(foo) > 2,
|
||||
}
|
||||
input:
|
||||
a: null
|
||||
query: data.test
|
||||
strict: false
|
||||
want_result:
|
||||
foo: null
|
||||
|
||||
- note: count of null error in strict mode
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
import rego.v1
|
||||
|
||||
foo := input.a
|
||||
|
||||
some_id := {
|
||||
"count_value": count(foo) > 2,
|
||||
(count(foo) > 2): "count_value",
|
||||
}
|
||||
input:
|
||||
a: null
|
||||
query: data.test
|
||||
error: "`count` requires array/object/set/string argument"
|
||||
|
||||
Reference in New Issue
Block a user