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

@@ -158,9 +158,11 @@ when defined(nimHasEnsureMove):
## Ensures that `x` is moved to the new location, otherwise it gives
## an error at the compile time.
runnableExamples:
var x = "Hello"
let y = ensureMove(x)
doAssert y == "Hello"
proc foo =
var x = "Hello"
let y = ensureMove(x)
doAssert y == "Hello"
foo()
discard "implemented in injectdestructors"
type