mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-29 10:01:39 +00:00
fixes #25208 ```nim type Conf = object val: int const defaultConf = Conf(val: 123) static: var conf: Conf conf = defaultConf ``` ```nim # opcLdConst is now always valid. We produce the necessary copy in the # assignments now: ``` A `opcLdConst` is generated for `defaultConf` in `conf = defaultConf`. According to the comment above, we need to handle the copy for assignments of `opcLdConst`
This commit is contained in:
@@ -794,3 +794,22 @@ block: # bug #23925
|
||||
static: # bug #21353
|
||||
var s: proc () = default(proc ())
|
||||
doAssert s == nil
|
||||
|
||||
# bug #25208
|
||||
|
||||
|
||||
type Conf = object
|
||||
val: int
|
||||
|
||||
const defaultConf = Conf(val: 123)
|
||||
|
||||
template foo2323(conf) =
|
||||
assert conf.val == 123
|
||||
var conf2 = conf
|
||||
assert conf2.val == 123
|
||||
|
||||
static:
|
||||
var conf: Conf = defaultConf
|
||||
conf = defaultConf # removing this results in the expected output
|
||||
conf.val = 2
|
||||
foo2323(defaultConf)
|
||||
|
||||
Reference in New Issue
Block a user