diff options
author | flywind <xzsflywind@gmail.com> | 2021-09-30 22:57:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-30 16:57:06 +0200 |
commit | 677969f6eaac108fc5fda776095a710c1b3b197a (patch) | |
tree | d3e8afb4b4d7d6f25d04e759816bd5d9df5620ba | |
parent | f915b3aa86929d87e162b6ddd7589e6337a30397 (diff) | |
download | Nim-677969f6eaac108fc5fda776095a710c1b3b197a.tar.gz |
alternative to #18918 (#18927)
* fix #16558 * add testcase
-rw-r--r-- | compiler/semexprs.nim | 2 | ||||
-rw-r--r-- | tests/arc/t16558.nim | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 9134c1301..342b8b05f 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -217,6 +217,8 @@ proc isCastable(c: PContext; dst, src: PType): bool = let s = skipTypes(src, abstractInst) if d.kind == tyRef and s.kind == tyRef and s[0].isFinal != d[0].isFinal: return false + elif d.kind in IntegralTypes and s.kind in {tyString, tySequence}: + return false var dstSize, srcSize: BiggestInt dstSize = computeSize(conf, dst) diff --git a/tests/arc/t16558.nim b/tests/arc/t16558.nim new file mode 100644 index 000000000..7b6eb4669 --- /dev/null +++ b/tests/arc/t16558.nim @@ -0,0 +1,9 @@ +discard """ + matrix: "--gc:arc" + errormsg: "expression cannot be cast to int" +""" + +block: # bug #16558 + var value = "hi there" + var keepInt: int + keepInt = cast[int](value) |