Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gear3: adds a type for arrayConstr #337

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/gear3/expander.nim
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,12 @@ proc traverseExpr(e: var EContext; c: var Cursor) =
e.dest.shrink beforeType
traverseExpr(e, c)
skipParRi(e, c)
of AconstrX:
e.dest.add tagToken("aconstr", c.info)
var arrayType = e.typeCache.getType(c)
inc c
e.traverseType(arrayType, {})
inc nested
of OconstrX:
e.dest.add tagToken("oconstr", c.info)
inc c
Expand Down
1 change: 1 addition & 0 deletions src/nimony/sem.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3362,6 +3362,7 @@ proc semArrayConstr(c: var SemContext, it: var Item) =
buildErr c, it.n.info, "empty array needs a specified type"
wantParRi c, it.n
return

var elem = Item(n: it.n, typ: c.types.autoType)
case it.typ.typeKind
of ArrayT: # , SeqT, OpenArrayT
Expand Down
24 changes: 24 additions & 0 deletions tests/nimony/sysbasics/tbasics.nif
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
(.nif24)
,1,tests/nimony/sysbasics/tbasics.nim(stmts 8,1
(type ~6 :Array.0.tbawx6nu81 . . . 7
(array ~11,5,lib/std/system.nim
(i -1)
(rangetype
(i -1) +0 +4))) 4,3
(var :s.0.tbawx6nu81 . .
(array
(i -1)
(rangetype
(i -1) +0 +2)) 4
(arr 1 +1 4 +2 7 +3)) 4,4
(var :s2.0.tbawx6nu81 . . 11,~3
(array ~11,5,lib/std/system.nim
(i -1)
(rangetype
(i -1) +0 +4)) .) 4,5
(var :s3.0.tbawx6nu81 . . 11,~4
(array ~11,5,lib/std/system.nim
(i -1)
(rangetype
(i -1) +0 +4)) 12
(arr 1 +1 4 +2 7 +3 10 +4 13 +5)))
6 changes: 6 additions & 0 deletions tests/nimony/sysbasics/tbasics.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type
Array = array[5, int]

var s = [1, 2, 3]
var s2: Array
var s3: Array = [1, 2, 3, 4, 5]
Loading