Closed rdaum closed 1 year ago
Error is in decompilation:
2023-09-22T11:50:07.354663Z WARN ThreadId(16) task_run: crates/kernel/src/vm/bf_verbs.rs:365: verb_code: verb program could not be decompiled object=#213 verb="session_for" error=malformed program: expected assign for optional scatter assignment
2023-09-22T11:50:07.356071602Z
2023-09-22T11:50:07.356076241Z Stack backtrace:
2023-09-22T11:50:07.356079628Z 0: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
2023-09-22T11:50:07.356083846Z at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/result.rs:1961:27
2023-09-22T11:50:07.356087082Z 1: moor_kernel::compiler::decompile::program_to_tree
2023-09-22T11:50:07.356090108Z at ./crates/kernel/src/compiler/decompile.rs:774:9
2023-09-22T11:50:07.356092963Z 2: moor_kernel::vm::bf_verbs::bf_verb_code::{{closure}}
Problematic statement: {who, ?package = $nothing} = args;
Disassemble from our code:
0: Push(Name(11)) (line 0)
1: Scatter { nargs: 2, nreq: 1, rest: 3, labels: [Required(Name(18)), Optional(Name(19), Some(Label(0)))], done: Label(1) }
2: Imm(Label(0))
3: Imm(Label(1))
4: GetProp
5: Put(Name(19))
6: Pop
7: Pop
8: Imm(Label(2)) (line 1)
9: MakeSingletonList
10: PushLabel(Label(2))
11: Catch(Label(2))
12: Push(Name(18))
Vs LambdaMOO:
0: 076 PUSH args
1: 112 013 002 001 003
018 000 019 011 018 * SCATTER 2/1/3: who/0 package/11 18
11: 100 000 PUSH_LITERAL #0
13: 100 001 PUSH_LITERAL "nothing"
15: 009 * GET_PROP
16: 053 * PUT package
17: 111 POP
18: 111 POP
19: 100 002 PUSH_LITERAL E_PROPNF
21: 016 * MAKE_SINGLETON_LIST
22: 112 002 034 PUSH_LABEL 34
And generated code of just this expression, outside of the rest of the verb:
[
Push(Name(11)),
Scatter {
nargs: 2, nreq: 1, rest: 3,
labels: [Required(Name(18)), Optional(Name(19), Some(Label(0)))],
done: Label(1)
},
Imm(Label(0)),
Imm(Label(1)),
GetProp,
Put(Name(19)),
Pop,
Pop,
Done
]
vs LambdaMOO:
0: 076 PUSH args
1: 112 013 002 001 003
018 000 019 011 018 * SCATTER 2/1/3: who/0 package/11 18
11: 100 000 PUSH_LITERAL #0
13: 100 001 PUSH_LITERAL "nothing"
15: 009 * GET_PROP
16: 053 * PUT package
17: 111 POP
18: 111 POP
Bug fixed in 664404a9e63ff9e10b1da16837fe50a86fff0648 Problem was actually with decompilation of all expressions in optional scatter assignments.
Either in decompilation, or in verb resolution.