Change the order of compilation passes, transformation is made lazy at code gen (#8489)
* Ast no transformation * Add getImplNoTransform to the macros module * progress on delaying transf * Fix methods tranformation * Fix lazy lambdalifting * fix create thread wrapper * transform for lambda lifting * improve getImplTransformed * Fix destructor tests * try to fix nimprof for linux
This commit is contained in:
parent
15dbd973de
commit
eaca5be9d6
22 changed files with 188 additions and 85 deletions
|
|
@ -1,12 +1,7 @@
|
|||
discard """
|
||||
errormsg: "'=' is not available for type <Foo>; requires a copy because it's not the last read of 'otherTree'"
|
||||
|
||||
cmd: "nim check --hint[Performance]:off $file"
|
||||
nimout: '''
|
||||
tprevent_assign2.nim(53, 31) Error: '=' is not available for type <Foo>; requires a copy because it's not the last read of 'otherTree'; another read is done here: tprevent_assign2.nim(52, 13)
|
||||
tprevent_assign2.nim(55, 31) Error: '=' is not available for type <Foo>; requires a copy because it's not the last read of 'otherTree'; another read is done here: tprevent_assign2.nim(52, 13)
|
||||
tprevent_assign2.nim(66, 29) Error: '=' is not available for type <Foo>; requires a copy because it's not the last read of 'otherTree'; another read is done here: tprevent_assign2.nim(68, 9)
|
||||
'''
|
||||
file: "tprevent_assign2.nim"
|
||||
line: 48
|
||||
"""
|
||||
|
||||
type
|
||||
|
|
@ -56,13 +51,5 @@ proc preventThis() =
|
|||
else:
|
||||
discard
|
||||
|
||||
proc preventThis2() =
|
||||
var otherTree: Foo
|
||||
try:
|
||||
try:
|
||||
otherTree = createTree(44)
|
||||
echo otherTree
|
||||
finally:
|
||||
take2(createTree(34), otherTree)
|
||||
finally:
|
||||
echo otherTree
|
||||
allowThis()
|
||||
preventThis()
|
||||
|
|
|
|||
53
tests/destructor/tprevent_assign3.nim
Normal file
53
tests/destructor/tprevent_assign3.nim
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
discard """
|
||||
errormsg: "'=' is not available for type <Foo>; requires a copy because it's not the last read of 'otherTree'"
|
||||
file: "tprevent_assign3.nim"
|
||||
line: 46
|
||||
"""
|
||||
|
||||
type
|
||||
Foo = object
|
||||
x: int
|
||||
|
||||
proc `=destroy`(f: var Foo) = f.x = 0
|
||||
proc `=`(a: var Foo; b: Foo) {.error.} # = a.x = b.x
|
||||
proc `=sink`(a: var Foo; b: Foo) = a.x = b.x
|
||||
|
||||
proc createTree(x: int): Foo =
|
||||
Foo(x: x)
|
||||
|
||||
proc take2(a, b: sink Foo) =
|
||||
echo a.x, " ", b.x
|
||||
|
||||
proc allowThis() =
|
||||
var otherTree: Foo
|
||||
try:
|
||||
for i in 0..3:
|
||||
while true:
|
||||
#if i == 0:
|
||||
otherTree = createTree(44)
|
||||
case i
|
||||
of 0:
|
||||
echo otherTree
|
||||
take2(createTree(34), otherTree)
|
||||
of 1:
|
||||
take2(createTree(34), otherTree)
|
||||
else:
|
||||
discard
|
||||
finally:
|
||||
discard
|
||||
|
||||
proc preventThis2() =
|
||||
var otherTree: Foo
|
||||
try:
|
||||
try:
|
||||
otherTree = createTree(44)
|
||||
echo otherTree
|
||||
finally:
|
||||
take2(createTree(34), otherTree)
|
||||
finally:
|
||||
echo otherTree
|
||||
|
||||
allowThis()
|
||||
preventThis2()
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue