Slight fix for var access

This commit is contained in:
2025-10-06 18:20:39 +11:00
parent e0ec910dc2
commit 8fea13cc17

View File

@@ -44,6 +44,12 @@ Value execute(Instruction inst) {
if (inst.instruction == InstructionType::Assert) { if (inst.instruction == InstructionType::Assert) {
return modules::assert(inst.args); return modules::assert(inst.args);
} }
// For all other instructions, evaluate the arguments first
for(auto& arg : inst.args) {
arg = evaluate(arg);
}
if (inst.instruction == InstructionType::Variable) { if (inst.instruction == InstructionType::Variable) {
auto& args = inst.args; auto& args = inst.args;
@@ -235,11 +241,6 @@ Value execute(Instruction inst) {
return Value(); return Value();
} }
// For all other instructions, evaluate the arguments first
for(auto& arg : inst.args) {
arg = evaluate(arg);
}
// Then, execute the instruction with the evaluated arguments // Then, execute the instruction with the evaluated arguments
switch (inst.instruction) { switch (inst.instruction) {
case InstructionType::Print: case InstructionType::Print: