fixes #14255; Crash in compiler when using system.any by accident. (#21562)

fixes #14255; Crash in compiler when using system.any by accident.
This commit is contained in:
ringabout
2023-03-23 23:10:14 +08:00
committed by GitHub
parent e8a70ff179
commit 55636a2913
2 changed files with 5 additions and 2 deletions

View File

@@ -302,7 +302,7 @@ proc semConv(c: PContext, n: PNode; expectedType: PType = nil): PNode =
result = newNodeI(nkConv, n.info)
var targetType = semTypeNode(c, n[0], nil)
case targetType.kind
case targetType.skipTypes({tyDistinct}).kind
of tyTypeDesc:
internalAssert c.config, targetType.len > 0
if targetType.base.kind == tyNone:

View File

@@ -5,6 +5,7 @@ discard """
t20588.nim(20, 12) Error: illegal type conversion to 'auto'
t20588.nim(21, 14) Error: illegal type conversion to 'typed'
t20588.nim(22, 16) Error: illegal type conversion to 'untyped'
t20588.nim(24, 7) Error: illegal type conversion to 'any'
'''
"""
@@ -16,7 +17,9 @@ t20588.nim(22, 16) Error: illegal type conversion to 'untyped'
discard 0.0.auto
discard typed("abc")
discard untyped(4)
var a = newSeq[bool](1000)
if any(a):
echo "ok?"