forked from ethereum/fe
-
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: reject infinite struct field definitions in analyzer, fixes: eth…
- Loading branch information
1 parent
4aa56e2
commit f4894be
Showing
6 changed files
with
83 additions
and
4 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
23 changes: 23 additions & 0 deletions
23
crates/analyzer/tests/snapshots/errors__struct_recursive_cycles.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,23 @@ | ||
--- | ||
source: crates/analyzer/tests/errors.rs | ||
expression: "error_string(&path, test_files::fixture(path))" | ||
--- | ||
error: recursive struct `Foo` | ||
┌─ compile_errors/struct_recursive_cycles.fe:4:8 | ||
│ | ||
4 │ struct Foo: | ||
│ ^^^ struct `Foo` has infinite size due to recursive definition | ||
|
||
error: recursive struct `Bar` | ||
┌─ compile_errors/struct_recursive_cycles.fe:8:8 | ||
│ | ||
8 │ struct Bar: | ||
│ ^^^ struct `Bar` has infinite size due to recursive definition | ||
|
||
error: recursive struct `Foo2` | ||
┌─ compile_errors/struct_recursive_cycles.fe:12:8 | ||
│ | ||
12 │ struct Foo2: | ||
│ ^^^^ struct `Foo2` has infinite size due to recursive definition | ||
|
||
|
22 changes: 22 additions & 0 deletions
22
crates/test-files/fixtures/compile_errors/struct_recursive_cycles.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,22 @@ | ||
|
||
# structs `Foo` and `Bar` contains indirect recursion | ||
# struct Foo depends on `Bar` | ||
struct Foo: | ||
x: Bar | ||
|
||
# struct Bar depends on `Foo` | ||
struct Bar: | ||
x: Foo | ||
|
||
# struct `Foo2` depends on itself - contains direct recursion | ||
struct Foo2: | ||
x: Foo2 | ||
|
||
# struct `Bar2` has no recursion | ||
struct Bar2: | ||
x: Foo | ||
y: Bar | ||
|
||
contract MyContract: | ||
pub fn func(foo: Foo, foo2: Foo2, bar2: Bar2): | ||
pass |