-
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.
Require KWargs for struct initialization
- Loading branch information
Showing
6 changed files
with
47 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
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
compiler/tests/fixtures/compile_errors/struct_call_without_kw_args.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,8 @@ | ||
struct House: | ||
vacant: bool | ||
price: u256 | ||
|
||
contract Foo: | ||
|
||
pub def bar(): | ||
my_house: House = House(true, price=1000000) |
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,15 @@ | ||
Require structs to be initialized using keyword arguments. | ||
|
||
Example: | ||
|
||
``` | ||
struct House: | ||
vacant: bool | ||
price: u256 | ||
``` | ||
|
||
Previously, `House` could be instantiated as `House(true, 1000000)`. | ||
With this change it is required to be instantiated like `House(vacant=true, price=1000000)` | ||
|
||
This ensures property assignment is less prone to get mixed up. It also makes struct | ||
initialization visually stand out more from function calls. |