Skip to content

Commit

Permalink
Add test for type def with const expression
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Nak committed Feb 3, 2022
1 parent 3e49eaa commit 2ae6870
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 29 deletions.

This file was deleted.

56 changes: 33 additions & 23 deletions crates/analyzer/tests/snapshots/analysis__module_const.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,42 @@ expression: "build_snapshot(&files, module_id, &db)"
note:
┌─ features/module_const.fe:1:1
1const C1: i32 = 1
^^^^^^^^^^^^^^^^^ i32
1type MY_ARRAY = Array<bool, { C4 }>
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array<bool, 42>

note:
┌─ features/module_const.fe:2:1
2const C2: i32 = C1 * 3
^^^^^^^^^^^^^^^^^^^^^^ i32
2const C1: i32 = 1
^^^^^^^^^^^^^^^^^ i32

note:
┌─ features/module_const.fe:3:1
3const C3: i32 = C4 + 2
3const C2: i32 = C1 * 3
^^^^^^^^^^^^^^^^^^^^^^ i32

note:
┌─ features/module_const.fe:4:1
4const C4: i32 = 42
4const C3: i32 = C4 + 2
^^^^^^^^^^^^^^^^^^^^^^ i32

note:
┌─ features/module_const.fe:5:1
5const C4: i32 = 42
^^^^^^^^^^^^^^^^^^ i32

note:
┌─ features/module_const.fe:7:5
┌─ features/module_const.fe:8:5
7 │ ╭ fn bar() -> i32:
8 │ │ const LOCAL_CONST: i32 = C3 * 2
9 │ │ let _arr1: Array<i32, { C2 }>
10 │ │ let _arr2: Array<i32, { LOCAL_CONST }>
11 │ │ return C4
8 │ ╭ fn bar() -> i32:
9 │ │ const LOCAL_CONST: i32 = C3 * 2
10 │ │ let _arr1: Array<i32, { C2 }>
11 │ │ let _arr2: Array<i32, { LOCAL_CONST }>
12 │ │ let _my_array: MY_ARRAY
13 │ │ return C4
│ ╰─────────────────^ attributes hash: 10625528290137096297
= FunctionSignature {
Expand All @@ -50,33 +57,36 @@ note:
}

note:
┌─ features/module_const.fe:8:28
┌─ features/module_const.fe:9:28
8const LOCAL_CONST: i32 = C3 * 2
9const LOCAL_CONST: i32 = C3 * 2
^^^ i32
9let _arr1: Array<i32, { C2 }>
10let _arr1: Array<i32, { C2 }>
^^^^^^^^^^^^^^^^^^ Array<i32, 3>
10let _arr2: Array<i32, { LOCAL_CONST }>
11let _arr2: Array<i32, { LOCAL_CONST }>
^^^^^^^^^^^^^^^^^^^^^^^^^^^ Array<i32, 88>
12let _my_array: MY_ARRAY
^^^^^^^^ Array<bool, 42>

note:
┌─ features/module_const.fe:8:34
┌─ features/module_const.fe:9:34
8const LOCAL_CONST: i32 = C3 * 2
9const LOCAL_CONST: i32 = C3 * 2
^^ ^ i32: Value
│ │
i32: Value

note:
┌─ features/module_const.fe:8:34
┌─ features/module_const.fe:9:34
8const LOCAL_CONST: i32 = C3 * 2
9const LOCAL_CONST: i32 = C3 * 2
^^^^^^ i32: Value
9let _arr1: Array<i32, { C2 }>
10let _arr1: Array<i32, { C2 }>
^^ i32: Value
10let _arr2: Array<i32, { LOCAL_CONST }>
11let _arr2: Array<i32, { LOCAL_CONST }>
^^^^^^^^^^^ i32: Value
11return C4
12let _my_array: MY_ARRAY
13return C4
^^ i32: Value


2 changes: 2 additions & 0 deletions crates/test-files/fixtures/features/module_const.fe
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
type MY_ARRAY = Array<bool, { C4 }>
const C1: i32 = 1
const C2: i32 = C1 * 3
const C3: i32 = C4 + 2
Expand All @@ -8,6 +9,7 @@ contract Foo:
const LOCAL_CONST: i32 = C3 * 2
let _arr1: Array<i32, { C2 }>
let _arr2: Array<i32, { LOCAL_CONST }>
let _my_array: MY_ARRAY
return C4


0 comments on commit 2ae6870

Please sign in to comment.