debugging::print builtin

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2023-03-04 04:34:10 -08:00
committed by Anand Krishnamoorthi
parent c5ea737200
commit ec695bd22e
3 changed files with 61 additions and 6 deletions

View File

@@ -1187,10 +1187,11 @@ impl<'source> Interpreter<'source> {
params: &'source Vec<Expr<'source>>,
) -> Result<Value> {
let mut args = vec![];
let allow_undefined = name == "print"; // TODO: with modifier
for p in params {
match self.eval_expr(p)? {
// If any argument is undefined, then the call is undefined.
Value::Undefined => return Ok(Value::Undefined),
Value::Undefined if !allow_undefined => return Ok(Value::Undefined),
p => args.push(p),
}
}