(cherry picked from commit 8054be6e52)
This commit is contained in:
Bung
2022-12-15 23:12:17 +08:00
committed by narimiran
parent 4ea0ce9149
commit f0324e99da
2 changed files with 24 additions and 0 deletions

View File

@@ -286,6 +286,8 @@ proc semConv(c: PContext, n: PNode): 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)

22
tests/arc/t20588.nim Normal file
View File

@@ -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)