-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure contract pure fns can be called via
ContractName::fn_name()
- Loading branch information
Showing
6 changed files
with
68 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
contract Example { | ||
|
||
pub fn run_test(self) { | ||
assert self.bar(42, 26) == 68 | ||
assert self.bar2(42, 26) == 68 | ||
} | ||
|
||
pub fn bar(self, _ x: u256, _ y: u256) -> u256 { | ||
return pure_bar(x, y) | ||
} | ||
|
||
pub fn bar2(self, _ x: u256, _ y: u256) -> u256 { | ||
return Example::pure_bar(x, y) | ||
} | ||
|
||
fn pure_bar(x: u256, y: u256) -> u256 { | ||
return x + y | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
crates/tests/src/snapshots/fe_compiler_tests__features__case_4_contract_pure_fns.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,7 @@ | ||
--- | ||
source: crates/tests/src/features.rs | ||
expression: "format!(\"{}\", harness.gas_reporter)" | ||
|
||
--- | ||
run_test([]) used 35 gas | ||
|
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 @@ | ||
Allow contract associated functions to be called via `ContractName::function_name()` syntax. |