From 55636a2913d0b0dec6b24568cb6baef43a9220c1 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 23 Mar 2023 23:10:14 +0800 Subject: [PATCH] fixes #14255; Crash in compiler when using `system.any` by accident. (#21562) fixes #14255; Crash in compiler when using system.any by accident. --- compiler/semexprs.nim | 2 +- tests/arc/t20588.nim | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index f74a72692bad5..d3c96ce3c42f1 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -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: diff --git a/tests/arc/t20588.nim b/tests/arc/t20588.nim index d747c656d369d..008bd1dcd3b32 100644 --- a/tests/arc/t20588.nim +++ b/tests/arc/t20588.nim @@ -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?" \ No newline at end of file