Skip to content

Conversation

@adam-mcdaniel
Copy link
Owner

In Sage, variables are pushed onto the stack when they're declared. This leads to issues in expressions like this:

let x = 5 * match 'a' {
    'a' => 6,
    'b' => 7,
    'c' => 8
};
println(x);

Here, the match expression generates an intermediate let binding for the bound expression 'a'. It thinks that this variable is stored just above the last variable on the stack, but 5 is actually stored there, the stack frame has grown in the mean time. So, this PR adds tracking of the stack frame for intermediate value and correctly compiles the code above.

@adam-mcdaniel adam-mcdaniel added bug Something isn't working Frontend📝 The frontend source code language LIR⚗️ Low Intermediate Representation and removed Frontend📝 The frontend source code language labels Sep 17, 2024
@adam-mcdaniel adam-mcdaniel merged commit 3eaeece into main Sep 18, 2024
@adam-mcdaniel adam-mcdaniel deleted the fix-let-args branch September 18, 2024 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working LIR⚗️ Low Intermediate Representation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants