mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-14 15:23:27 +00:00
* Fix #11684 For loops over a hardcoded empty array crash the compiler
* Update t19224.nim
(cherry picked from commit 567c3f055d)
This commit is contained in:
@@ -767,6 +767,9 @@ proc semForVars(c: PContext, n: PNode; flags: TExprFlags): PNode =
|
||||
var iterAfterVarLent = iter.skipTypes({tyGenericInst, tyAlias, tyLent, tyVar})
|
||||
# n.len == 3 means that there is one for loop variable
|
||||
# and thus no tuple unpacking:
|
||||
if iterAfterVarLent.kind == tyEmpty:
|
||||
localError(c.config, n[^2].info, "cannot infer element type of $1" %
|
||||
renderTree(n[^2], {renderNoComments}))
|
||||
if iterAfterVarLent.kind != tyTuple or n.len == 3:
|
||||
if n.len == 3:
|
||||
if n[0].kind == nkVarTuple:
|
||||
|
||||
12
tests/errmsgs/t19224.nim
Normal file
12
tests/errmsgs/t19224.nim
Normal file
@@ -0,0 +1,12 @@
|
||||
discard """
|
||||
cmd: "nim check --hints:off $file"
|
||||
errormsg: ""
|
||||
nimout: '''
|
||||
t19224.nim(10, 10) Error: cannot infer element type of items([])
|
||||
t19224.nim(12, 10) Error: cannot infer element type of items(@[])
|
||||
'''
|
||||
"""
|
||||
|
||||
for _ in []: discard
|
||||
|
||||
for _ in @[]: discard
|
||||
Reference in New Issue
Block a user