feat: functions with formal parameters
This commit is contained in:
@@ -173,4 +173,7 @@ fn test_func() {
|
||||
test_expr("(x: x) 1", int!(1));
|
||||
test_expr("(x: x) (x: x) 1", int!(1));
|
||||
test_expr("(x: y: x + y) 1 1", int!(2));
|
||||
test_expr("({ x, y }: x + y) { x = 1; y = 2; }", int!(3));
|
||||
test_expr("({ x, y, ... }: x + y) { x = 1; y = 2; z = 3; }", int!(3));
|
||||
test_expr("(inputs@{ x, y, ... }: x + inputs.y) { x = 1; y = 2; z = 3; }", int!(3));
|
||||
}
|
||||
|
||||
@@ -111,9 +111,6 @@ impl VM {
|
||||
OpCode::SetAlias { sym } => {
|
||||
stack.tos_mut()?.as_mut().unwrap_func().set_alias(sym);
|
||||
}
|
||||
OpCode::Ret => {
|
||||
todo!()
|
||||
}
|
||||
OpCode::UnOp { op } => {
|
||||
use UnOp::*;
|
||||
let value = stack.pop()?;
|
||||
@@ -200,7 +197,7 @@ impl VM {
|
||||
)?;
|
||||
}
|
||||
OpCode::EnterEnv => {
|
||||
env.enter(stack.pop()?.unwrap_attr_set().to_data());
|
||||
env.enter(stack.pop()?.unwrap_attr_set().into_inner());
|
||||
}
|
||||
OpCode::LeaveEnv => {
|
||||
env.leave();
|
||||
|
||||
Reference in New Issue
Block a user