mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-26 00:21:42 +00:00
fixes #26104; prevent compile-time-only typeof from being treated as a runtime alias
This commit is contained in:
16
tests/ccgbugs/t26104.nim
Normal file
16
tests/ccgbugs/t26104.nim
Normal 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()
|
||||
Reference in New Issue
Block a user