From 1a6837b866aaf631eeafd083557db7ecc2e8937e Mon Sep 17 00:00:00 2001 From: Zekun Wang Date: Fri, 15 Mar 2024 03:54:38 -0400 Subject: [PATCH] upate tests --- .../checking/typing/recursive_struct.exp | 86 ++++++----- .../checking/typing/recursive_struct.move | 136 ++++++++++-------- 2 files changed, 122 insertions(+), 100 deletions(-) diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.exp b/third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.exp index 1028ca7852fda4..81eb71301c60b0 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.exp @@ -1,7 +1,7 @@ Diagnostics: error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:5:2 + ┌─ tests/checking/typing/recursive_struct.move:5:5 │ 5 │ ╭ struct T { 6 │ │ f: S @@ -12,7 +12,7 @@ error: cyclic data = field `f` of `S` contains `T`, which forms a cycle. error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:9:2 + ┌─ tests/checking/typing/recursive_struct.move:9:5 │ 9 │ ╭ struct S1 { 10 │ │ f: S2 @@ -24,7 +24,7 @@ error: cyclic data = field `f` of `S3` contains `S1`, which forms a cycle. error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:21:2 + ┌─ tests/checking/typing/recursive_struct.move:21:5 │ 21 │ ╭ struct S4 { 22 │ │ f: S4 @@ -34,7 +34,7 @@ error: cyclic data = field `f` of `S4` contains `S4`, which forms a cycle. error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:25:2 + ┌─ tests/checking/typing/recursive_struct.move:25:5 │ 25 │ ╭ struct S5 { 26 │ │ f: S5 @@ -44,7 +44,7 @@ error: cyclic data = field `f` of `S5` contains `S5`, which forms a cycle. error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:33:2 + ┌─ tests/checking/typing/recursive_struct.move:33:5 │ 33 │ ╭ struct S7 { 34 │ │ f: S7 @@ -54,76 +54,88 @@ error: cyclic data = field `f` of `S7` contains `S7`, which forms a cycle. error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:39:2 + ┌─ tests/checking/typing/recursive_struct.move:37:5 │ -39 │ ╭ struct S { -40 │ │ f: G +37 │ ╭ struct X { +38 │ │ f: Y, +39 │ │ g: Y, +40 │ │ } + │ ╰─────^ + │ + = field `f` of `X` contains `Y` + = field `f` of `Y` contains `X`, which forms a cycle. + +error: cyclic data + ┌─ tests/checking/typing/recursive_struct.move:49:5 + │ +49 │ ╭ struct S { +50 │ │ f: G │ │ - invalid field f of S containing S itself -41 │ │ } +51 │ │ } │ ╰─────^ error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:43:2 + ┌─ tests/checking/typing/recursive_struct.move:53:5 │ -43 │ ╭ struct U { -44 │ │ f: G> +53 │ ╭ struct U { +54 │ │ f: G> │ │ - invalid field f of U containing U itself -45 │ │ } +55 │ │ } │ ╰─────^ error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:51:2 + ┌─ tests/checking/typing/recursive_struct.move:61:5 │ -51 │ ╭ struct S1 { -52 │ │ f: vector +61 │ ╭ struct S1 { +62 │ │ f: vector │ │ - invalid field f of S1 containing S1 itself -53 │ │ } +63 │ │ } │ ╰─────^ error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:55:2 + ┌─ tests/checking/typing/recursive_struct.move:65:5 │ -55 │ ╭ struct S2 { -56 │ │ f: S3> -57 │ │ } +65 │ ╭ struct S2 { +66 │ │ f: S3> +67 │ │ } │ ╰─────^ │ = field `f` of `S2` contains `S3` = field `f` of `S3` contains `S2`, which forms a cycle. error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:55:2 + ┌─ tests/checking/typing/recursive_struct.move:65:5 │ -55 │ ╭ struct S2 { -56 │ │ f: S3> +65 │ ╭ struct S2 { +66 │ │ f: S3> │ │ - invalid field f of S2 containing S2 itself -57 │ │ } +67 │ │ } │ ╰─────^ error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:59:2 + ┌─ tests/checking/typing/recursive_struct.move:69:5 │ -59 │ ╭ struct S3 { -60 │ │ f: S2> +69 │ ╭ struct S3 { +70 │ │ f: S2> │ │ - invalid field f of S3 containing S3 itself -61 │ │ } +71 │ │ } │ ╰─────^ error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:63:2 + ┌─ tests/checking/typing/recursive_struct.move:73:5 │ -63 │ ╭ struct S4 { -64 │ │ f: S4> -65 │ │ } +73 │ ╭ struct S4 { +74 │ │ f: S4> +75 │ │ } │ ╰─────^ │ = field `f` of `S4` contains `S4`, which forms a cycle. error: cyclic data - ┌─ tests/checking/typing/recursive_struct.move:63:2 + ┌─ tests/checking/typing/recursive_struct.move:73:5 │ -63 │ ╭ struct S4 { -64 │ │ f: S4> +73 │ ╭ struct S4 { +74 │ │ f: S4> │ │ - invalid field f of S4 containing S4 itself -65 │ │ } +75 │ │ } │ ╰─────^ diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.move b/third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.move index a0a6365a86a196..aebd6409ee3a56 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.move +++ b/third_party/move/move-compiler-v2/tests/checking/typing/recursive_struct.move @@ -1,77 +1,87 @@ 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 { - f: S4 - } - - struct S5 { - f: S5 - } - - struct S6 { - f: S7 - } - - struct S7 { - f: S7 - } + struct S { + f: T + } + struct T { + f: S + } + + struct S1 { + f: S2 + } + + struct S2 { + f: S3 + } + + struct S3 { + f: S1 + } + + struct S4 { + f: S4 + } + + struct S5 { + f: S5 + } + + struct S6 { + f: S7 + } + + struct S7 { + f: S7 + } + + struct X { + f: Y, + g: Y, + } + + struct Y { + f: X, + g: X + } } module 0x42::type_param { - struct S { - f: G - } + struct S { + f: G + } - struct U { - f: G> - } + struct U { + f: G> + } - struct G { - f: T - } + struct G { + f: T + } - struct S1 { - f: vector - } + struct S1 { + f: vector + } - struct S2 { - f: S3> - } + struct S2 { + f: S3> + } - struct S3 { - f: S2> - } + struct S3 { + f: S2> + } - struct S4 { - f: S4> - } + struct S4 { + f: S4> + } } module 0x42::instantiate_with_self { - struct S { - f: T - } - - struct U { - // this is ok - f: S> - } + struct S { + f: T + } + + struct U { + // this is ok + f: S> + } }