fixes #26104; prevent compile-time-only typeof from being treated a… (#26105)

…s a runtime alias

fixes #26104

Follows up https://github.com/nim-lang/Nim/pull/25994
This commit is contained in:
ringabout
2026-08-14 19:36:55 +08:00
committed by GitHub
parent ebfd1c5090
commit cbb3b065c7
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: "@'((*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()