mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
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
(cherry picked from commit cd3cf3a20e)
This commit is contained in:
@@ -161,9 +161,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
|
||||
|
||||
@@ -700,3 +700,19 @@ block: # bug #23505
|
||||
C(value: addr tmp[])
|
||||
|
||||
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()
|
||||
|
||||
@@ -137,28 +137,29 @@ doAssert seq3[0] == 1.0
|
||||
var seq4, seq5: MySeqNonCopyable
|
||||
(seq4, i, seq5) = myfunc2(2, 3)
|
||||
|
||||
seq4 = block:
|
||||
var tmp = newMySeq(4, 1.0)
|
||||
tmp[0] = 3.0
|
||||
tmp
|
||||
proc foo =
|
||||
seq4 = block:
|
||||
var tmp = newMySeq(4, 1.0)
|
||||
tmp[0] = 3.0
|
||||
tmp
|
||||
|
||||
doAssert seq4[0] == 3.0
|
||||
doAssert seq4[0] == 3.0
|
||||
|
||||
import macros
|
||||
|
||||
seq4 =
|
||||
if i > 0: newMySeq(2, 5.0)
|
||||
elif i < -100: raise newException(ValueError, "Parse Error")
|
||||
else: newMySeq(2, 3.0)
|
||||
seq4 =
|
||||
if i > 0: newMySeq(2, 5.0)
|
||||
elif i < -100: raise newException(ValueError, "Parse Error")
|
||||
else: newMySeq(2, 3.0)
|
||||
|
||||
seq4 =
|
||||
case (char) i:
|
||||
of 'A', {'W'..'Z'}: newMySeq(2, 5.0)
|
||||
of 'B': quit(-1)
|
||||
else:
|
||||
let (x1, x2, x3) = myfunc2(2, 3)
|
||||
x3
|
||||
seq4 =
|
||||
case (char) i:
|
||||
of 'A', {'W'..'Z'}: newMySeq(2, 5.0)
|
||||
of 'B': quit(-1)
|
||||
else:
|
||||
let (x1, x2, x3) = myfunc2(2, 3)
|
||||
x3
|
||||
|
||||
foo()
|
||||
|
||||
#------------------------------------------------------------
|
||||
#-- Move into array constructor
|
||||
|
||||
Reference in New Issue
Block a user