fix!(codegen): reset function outputs and default omitted arguments - #1958
Open
Angus-Bethke-Bachmann wants to merge 5 commits into
Open
Angus-Bethke-Bachmann wants to merge 5 commits into
Angus-Bethke-Bachmann wants to merge 5 commits into
Conversation
|
3 findings in 4m 31s for $0.73 between
|
Build Artifacts🐧 Linux
From workflow run 🪟 Windows
From workflow run |
|
2 findings in 5m 10s for $0.72 between
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@ghaith or @volsa this one needs a careful review, it made some assumptions in codegen that seem right... but a few of the polymorphism tests have been changed. So a double check of this is probably necessary.
Problem: When a call left out an argument, the compiler passed the contents of a stack slot that nothing had written. The callee then saw whatever the previous call had left there. A VAR_OUTPUT of a function or method also started every call with the caller's current value, so a path that did not assign the output leaked that value back to the caller.
Solution: An argument that is left out, or written empty, now carries the declared default or zero. Every VAR_OUTPUT of a function or method is initialized like a local variable at the start of the call: codegen zero-fills it through the caller's address, and the init lowering adds the constructor call and the initializer assignment. Variable length array outputs keep the caller's bounds and are not reset. Reading an output before assigning it now gives its default, so callers no longer observe stale values. One known effect is that passing the same variable as an output and as an in-out of one call makes the body read zero; the book documents this.
Refs: PRG-4940
🤖 Generated with Claude Code