Skip to content

Commit

Permalink
Fixes #183: Using the basic optimizations can also cause problems wit…
Browse files Browse the repository at this point in the history
…h the output
  • Loading branch information
cardillan committed Dec 7, 2024
1 parent d7e237f commit dbf6748
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ private LogicValue handleStacklessFunctionCall(LogicFunction function, List<Logi
// Use GOTO_OFFSET for list iterator, drop marker from GOTO and target simple labels
emit(createGotoLabel(returnLabel, LogicLabel.symbolic(functionPrefix)));

setSubcontextType(function, AstSubcontextType.PARAMETERS);
retrieveFunctionParameters(function, arguments, false);
return passReturnValue(function);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,28 @@ def foo(n)
);
}

@Test
void inlinesFunctionWithOutputParameter() {
assertCompilesTo("""
param c = 10;
void foo(a, out b)
b = c * a;
end;
foo(10, out x);
foo(20, out y);
print(x, y);
""",
createInstruction(SET, "c", "10"),
createInstruction(OP, "mul", "__fn0_b", "c", "10"),
createInstruction(SET, "x", "__fn0_b"),
createInstruction(OP, "mul", "__fn0_b", "c", "20"),
createInstruction(PRINT, "x"),
createInstruction(PRINT, "__fn0_b")
);
}

@Test
void inlinesTwoFunction() {
assertCompilesTo("""
Expand Down

0 comments on commit dbf6748

Please sign in to comment.