forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug in the IR parsing. (FuelLabs#2442)
When resolving calls after recreating the IR from parsed input as a second pass the old code would inject a NOP where the CALL should go and replace it with a resolved CALL. This was a problem when the call value was used as an argument to another call, as the NOP was taken rather than the CALL. Attempting to replace the NOP everywhere was very tricky (I couldn't actually manage it in the end). A better (though still a bit hacky) approach now is to inject a CALL from the start, but to a dummy function and replace that function within the CALL in the resolving pass. This way any references to the call value are valid from the start.
- Loading branch information
Showing
4 changed files
with
61 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// This script was causing a verification error: | ||
// An untyped/void value has been passed to a function call. | ||
// Based on the `v2 = call a(v1)` line | ||
|
||
script { | ||
// check: fn main | ||
fn main() -> bool { | ||
entry: | ||
v0 = const bool true | ||
v1 = call a(v0) | ||
v2 = call a(v1) | ||
ret bool v2 | ||
} | ||
|
||
fn a(x: bool) -> bool { | ||
entry: | ||
v0 = const bool true | ||
ret bool v0 | ||
} | ||
} |