Skip to content

Commit

Permalink
fix #20588 (#21104)
Browse files Browse the repository at this point in the history
  • Loading branch information
bung87 authored Dec 15, 2022
1 parent d88f46d commit 8054be6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ proc semConv(c: PContext, n: PNode; expectedType: PType = nil): PNode =
return evaluated
else:
targetType = targetType.base
of tyAnything, tyUntyped, tyTyped:
localError(c.config, n.info, "illegal type conversion to '$1'" % typeToString(targetType))
else: discard

maybeLiftType(targetType, c, n[0].info)
Expand Down
22 changes: 22 additions & 0 deletions tests/arc/t20588.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
discard """
cmd: "nim check --warnings:off --hints:off $file"
errormsg: ""
nimout: '''
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'
'''
"""










discard 0.0.auto
discard typed("abc")
discard untyped(4)

0 comments on commit 8054be6

Please sign in to comment.