fixes #23524; global variables cannot be analysed when injecting move (#23529)

fixes #23524

```nim
proc isAnalysableFieldAccess*(orig: PNode; owner: PSym): bool =
  ...
  result = n.kind == nkSym and n.sym.owner == owner and
    {sfGlobal, sfThread, sfCursor} * n.sym.flags == {} and
    (n.sym.kind != skParam or isSinkParam(n.sym))
```
In `isAnalysableFieldAccess`, globals, cursors are already rejected
This commit is contained in:
ringabout
2024-04-24 18:47:05 +08:00
committed by GitHub
parent 7e3bac9235
commit cd3cf3a20e
4 changed files with 41 additions and 23 deletions

View File

@@ -727,3 +727,18 @@ block: # bug #23505
discard init(C)
block: # bug #23524
type MyType = object
a: int
proc `=destroy`(typ: MyType) = discard
var t1 = MyType(a: 100)
var t2 = t1 # Should be a copy?
proc main() =
t2 = t1
doAssert t1.a == 100
doAssert t2.a == 100
main()