-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zekun Wang
committed
Feb 27, 2024
1 parent
5fa9fe2
commit 3f373e6
Showing
2 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.exp
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,112 @@ | ||
|
||
Diagnostics: | ||
error: recursive definition S | ||
┌─ tests/checking/typing/recursive_struct.move:2:2 | ||
│ | ||
2 │ ╭ struct S { | ||
3 │ │ f: T | ||
4 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S contains T... | ||
= T contains S, which forms a loop. | ||
|
||
error: recursive definition T | ||
┌─ tests/checking/typing/recursive_struct.move:5:2 | ||
│ | ||
5 │ ╭ struct T { | ||
6 │ │ f: S | ||
7 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= T contains S... | ||
= S contains T, which forms a loop. | ||
|
||
error: recursive definition S1 | ||
┌─ tests/checking/typing/recursive_struct.move:9:2 | ||
│ | ||
9 │ ╭ struct S1 { | ||
10 │ │ f: S2 | ||
11 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S1 contains S2... | ||
= S2 contains S3... | ||
= S3 contains S1, which forms a loop. | ||
|
||
error: recursive definition S2 | ||
┌─ tests/checking/typing/recursive_struct.move:13:2 | ||
│ | ||
13 │ ╭ struct S2 { | ||
14 │ │ f: S3 | ||
15 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S2 contains S3... | ||
= S3 contains S1... | ||
= S1 contains S2, which forms a loop. | ||
|
||
error: recursive definition S3 | ||
┌─ tests/checking/typing/recursive_struct.move:17:2 | ||
│ | ||
17 │ ╭ struct S3 { | ||
18 │ │ f: S1 | ||
19 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S3 contains S1... | ||
= S1 contains S2... | ||
= S2 contains S3, which forms a loop. | ||
|
||
error: recursive definition S4 | ||
┌─ tests/checking/typing/recursive_struct.move:21:2 | ||
│ | ||
21 │ ╭ struct S4<T> { | ||
22 │ │ f: S4<bool> | ||
23 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S4 contains S4, which forms a loop. | ||
|
||
error: recursive definition S | ||
┌─ tests/checking/typing/recursive_struct.move:27:2 | ||
│ | ||
27 │ ╭ struct S { | ||
28 │ │ f: G<S> | ||
29 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S contains G... | ||
= G contains S, which forms a loop. | ||
|
||
error: recursive definition S1 | ||
┌─ tests/checking/typing/recursive_struct.move:35:2 | ||
│ | ||
35 │ ╭ struct S1 { | ||
36 │ │ f: vector<S1> | ||
37 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S1 contains S1, which forms a loop. | ||
|
||
error: recursive definition S2 | ||
┌─ tests/checking/typing/recursive_struct.move:39:2 | ||
│ | ||
39 │ ╭ struct S2<T1, T2> { | ||
40 │ │ f: S3<u8, S2<T1, T2>> | ||
41 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S2 contains S3... | ||
= S3 contains S2, which forms a loop. | ||
|
||
error: recursive definition S3 | ||
┌─ tests/checking/typing/recursive_struct.move:43:2 | ||
│ | ||
43 │ ╭ struct S3<T1, T2> { | ||
44 │ │ f: S2<u8, S3<u8, u8>> | ||
45 │ │ } | ||
│ ╰─────^ | ||
│ | ||
= S3 contains S2... | ||
= S2 contains S3, which forms a loop. |
46 changes: 46 additions & 0 deletions
46
third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.move
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,46 @@ | ||
module 0x42::simple_recursion { | ||
struct S { | ||
f: T | ||
} | ||
struct T { | ||
f: S | ||
} | ||
|
||
struct S1 { | ||
f: S2 | ||
} | ||
|
||
struct S2 { | ||
f: S3 | ||
} | ||
|
||
struct S3 { | ||
f: S1 | ||
} | ||
|
||
struct S4<T> { | ||
f: S4<bool> | ||
} | ||
} | ||
|
||
module 0x42::type_param { | ||
struct S { | ||
f: G<S> | ||
} | ||
|
||
struct G<T> { | ||
f: T | ||
} | ||
|
||
struct S1 { | ||
f: vector<S1> | ||
} | ||
|
||
struct S2<T1, T2> { | ||
f: S3<u8, S2<T1, T2>> | ||
} | ||
|
||
struct S3<T1, T2> { | ||
f: S2<u8, S3<u8, u8>> | ||
} | ||
} |