mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 05:50:30 +00:00
fixes #24258 It uses conditionals to guard against ill formed AST to produce better error messages, rather than crashing
This commit is contained in:
@@ -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)
|
||||
|
||||
10
tests/errmsgs/t24258.nim
Normal file
10
tests/errmsgs/t24258.nim
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user