feat(machine): fix Value::Constr fields order

cc @MicroProofs
This commit is contained in:
rvcas 2024-02-19 20:52:38 -05:00 committed by Lucas
parent 028528899c
commit 20917bbd5b
4 changed files with 13 additions and 4 deletions

View File

@ -163,8 +163,10 @@ impl Machine {
Term::Constr { tag, mut fields } => {
self.step_and_maybe_spend(StepKind::Constr)?;
fields.reverse();
if !fields.is_empty() {
let popped_field = fields.remove(0);
let popped_field = fields.pop().unwrap();
Ok(MachineState::Compute(
Context::FrameConstr(env.clone(), tag, fields, vec![], context.into()),
@ -213,10 +215,10 @@ impl Machine {
Context::FrameAwaitArg(fun, ctx) => self.apply_evaluate(*ctx, fun, value),
Context::FrameAwaitFunValue(arg, ctx) => self.apply_evaluate(*ctx, value, arg),
Context::FrameConstr(env, tag, mut fields, mut resolved_fields, ctx) => {
resolved_fields.insert(0, value);
resolved_fields.push(value);
if !fields.is_empty() {
let popped_field = fields.remove(0);
let popped_field = fields.pop().unwrap();
Ok(MachineState::Compute(
Context::FrameConstr(env.clone(), tag, fields, resolved_fields, ctx),
@ -376,7 +378,7 @@ fn transfer_arg_stack(mut args: Vec<Value>, ctx: Context) -> Context {
if args.is_empty() {
ctx
} else {
let popped_field = args.remove(0);
let popped_field = args.pop().unwrap();
transfer_arg_stack(args, Context::FrameAwaitFunValue(popped_field, ctx.into()))
}

View File

@ -0,0 +1,4 @@
-- constr can have arbitrary terms in it
(program 1.1.0
(constr 1 (con integer 1) (lam x x) (constr 0 (con integer 1)))
)

View File

@ -0,0 +1,2 @@
({cpu: 115100
| mem: 600})

View File

@ -0,0 +1 @@
(program 1.1.0 (constr 1 (con integer 1) (lam x x) (constr 0 (con integer 1))))