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.
Fixes local const shadowed by global const with same name. (FuelLabs#…
…3402) With PR FuelLabs#3233 `compile_const_decl` is now able to check for local variables. To fix the issue described in FuelLabs#3237 we need to pass the `FnCompiler` to `compile_constant_expression` so it can check the local variables in use. Closes FuelLabs#3237
- Loading branch information
Showing
6 changed files
with
51 additions
and
1 deletion.
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
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/language/const_global_shadow/Forc.lock
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,8 @@ | ||
[[package]] | ||
name = 'const_global_shadow' | ||
source = 'member' | ||
dependencies = ['core'] | ||
|
||
[[package]] | ||
name = 'core' | ||
source = 'path+from-root-37F288FECEE71F89' |
8 changes: 8 additions & 0 deletions
8
test/src/e2e_vm_tests/test_programs/should_pass/language/const_global_shadow/Forc.toml
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,8 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
license = "Apache-2.0" | ||
name = "const_global_shadow" | ||
entry = "main.sw" | ||
|
||
[dependencies] | ||
core = { path = "../../../../../../../sway-lib-core" } |
22 changes: 22 additions & 0 deletions
22
.../e2e_vm_tests/test_programs/should_pass/language/const_global_shadow/json_abi_oracle.json
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,22 @@ | ||
{ | ||
"functions": [ | ||
{ | ||
"inputs": [], | ||
"name": "main", | ||
"output": { | ||
"name": "", | ||
"type": 0, | ||
"typeArguments": null | ||
} | ||
} | ||
], | ||
"loggedTypes": [], | ||
"types": [ | ||
{ | ||
"components": null, | ||
"type": "u64", | ||
"typeId": 0, | ||
"typeParameters": null | ||
} | ||
] | ||
} |
9 changes: 9 additions & 0 deletions
9
test/src/e2e_vm_tests/test_programs/should_pass/language/const_global_shadow/src/main.sw
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,9 @@ | ||
script; | ||
|
||
const GLOBAL_VAL: u64 = 1; | ||
|
||
fn main() -> u64 { | ||
const GLOBAL_VAL = 100; | ||
const LOCAL_VAL = GLOBAL_VAL; | ||
LOCAL_VAL | ||
} |
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_pass/language/const_global_shadow/test.toml
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,3 @@ | ||
category = "run" | ||
expected_result = { action = "return", value = 100 } | ||
validate_abi = true |