-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reject to_mem on primitive types in storage
- Loading branch information
Showing
5 changed files
with
38 additions
and
2 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
14 changes: 14 additions & 0 deletions
14
crates/analyzer/tests/snapshots/errors__call_to_mem_on_primitive.snap
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,14 @@ | ||
--- | ||
source: crates/analyzer/tests/errors.rs | ||
expression: "error_string(&path, test_files::fixture(path))" | ||
|
||
--- | ||
error: `to_mem()` called on primitive type | ||
┌─ compile_errors/call_to_mem_on_primitive.fe:5:16 | ||
│ | ||
5 │ return self.bar.to_mem() | ||
│ ^^^^^^^^ ------ hint: remove `.to_mem()` | ||
│ │ | ||
│ this value does not need to be copied to memory | ||
|
||
|
7 changes: 7 additions & 0 deletions
7
crates/test-files/fixtures/compile_errors/call_to_mem_on_primitive.fe
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,7 @@ | ||
contract Foo { | ||
bar: u256 | ||
|
||
fn call_me(self) -> u256 { | ||
return self.bar.to_mem() | ||
} | ||
} |
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 @@ | ||
Reject calling `to_mem()` on primitive types in storage |