diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-09-28 19:57:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-28 13:57:47 +0200 |
commit | e33e9e4a32ea19654d1940ad0c17da8490a99f6c (patch) | |
tree | 6fe32741e95ce04fffafc02f6f591680d59ad210 /tests/ccgbugs/t20141.nim | |
parent | fe8feb46c6b69d2a2b63c83af88d0f9f03a31435 (diff) | |
download | Nim-e33e9e4a32ea19654d1940ad0c17da8490a99f6c.tar.gz |
fixes #20141; dereferencing pointer to incomplete type error with cast (#20147)
Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
Diffstat (limited to 'tests/ccgbugs/t20141.nim')
-rw-r--r-- | tests/ccgbugs/t20141.nim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/ccgbugs/t20141.nim b/tests/ccgbugs/t20141.nim new file mode 100644 index 000000000..499cd21aa --- /dev/null +++ b/tests/ccgbugs/t20141.nim @@ -0,0 +1,27 @@ +discard """ + joinable: false +""" + +# bug #20141 +type + A = object + B = object + U = proc() + +proc m(h: var B) = discard + +template n[T, U](x: U): T = + static: doAssert true + cast[ptr T](addr x)[] + +proc k() = + var res: A + m(n[B](res)) + +proc w(mounter: U) = discard + +proc mount(proto: U) = discard +proc v() = mount k + +# This is required for failure +w(v) \ No newline at end of file |