Skip to content

Commit

Permalink
fixes #24258; compiler crash on len of varargs[untyped]
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Oct 14, 2024
1 parent 34c87de commit 23f3926
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler/renderer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1311,10 +1311,11 @@ proc gsub(g: var TSrcGen, n: PNode, c: TContext, fromStmtList = false) =
put(g, tkCustomLit, n[0].strVal)
gsub(g, n, 1)
else:
gsub(g, n, 0)
for i in 0..<n.len-1:
gsub(g, n, i)
put(g, tkDot, ".")
assert n.len == 2, $n.len
accentedName(g, n[1])
if n.len > 1:
accentedName(g, n[^1])
of nkBind:
putWithSpace(g, tkBind, "bind")
gsub(g, n, 0)
Expand Down
10 changes: 10 additions & 0 deletions tests/errmsgs/t24258.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
discard """
cmd: "nim check $file"
errormsg: "illformed AST: [22]43.len"
joinable: false
"""

template encodeList*(args: varargs[untyped]): seq[byte] =
@[byte args.len]

let x = encodeList([22], 43)

0 comments on commit 23f3926

Please sign in to comment.