Skip to content

Commit

Permalink
fixes #14255; Crash in compiler when using system.any by accident. (#…
Browse files Browse the repository at this point in the history
…21562)

fixes #14255; Crash in compiler when using system.any by accident.
  • Loading branch information
ringabout authored Mar 23, 2023
1 parent e8a70ff commit 55636a2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion tests/arc/t20588.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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'
'''
"""

Expand All @@ -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?"

0 comments on commit 55636a2

Please sign in to comment.