fixes #26104; prevent compile-time-only typeof from being treated as a runtime alias

This commit is contained in:
ringabout
2026-08-13 22:08:24 +08:00
parent ebfd1c5090
commit b2bab45e23
2 changed files with 29 additions and 0 deletions

16
tests/ccgbugs/t26104.nim Normal file
View File

@@ -0,0 +1,16 @@
discard """
action: compile
ccodeCheck: "@'f_.*((*Result).f)' .*"
"""
# bug #26104: a compile-time-only `typeof` argument was treated as a runtime
# alias of the result field, forcing an unnecessarily large temporary and copy.
type
B = array[131072, byte]
Y = object
f: B
proc fill(_: type B): B = discard
proc make(): Y = result.f = fill(typeof(result.f))
discard make()