mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-06 13:07:48 +00:00
* WIP: an optimizer for ARC * do not optimize away destructors in 'finally' if unstructured control flow is involved * optimized the optimizer * minor code cleanup * first steps to .cursor inference * cursor inference: big steps to a working solution * baby steps * better .cursor inference * new feature: expandArc for easy inspection of the AST after ARC transformations * added topt_cursor test * adapt tests * cleanups, make tests green * optimize common traversal patterns * moved test case * fixes .cursor inference so that npeg compiles once again * cursor inference: more bugfixes Co-authored-by: Clyybber <darkmine956@gmail.com>
44 lines
671 B
Nim
44 lines
671 B
Nim
discard """
|
|
output: '''@[0]
|
|
@[1]
|
|
@[2]
|
|
@[3]'''
|
|
joinable: false
|
|
"""
|
|
|
|
# bug #6434
|
|
|
|
type
|
|
Foo* = object
|
|
boo: int
|
|
|
|
var sink_counter = 0
|
|
var assign_counter = 0
|
|
|
|
proc `=sink`(dest: var Foo, src: Foo) =
|
|
sink_counter.inc
|
|
|
|
proc `=`(dest: var Foo, src: Foo) =
|
|
assign_counter.inc
|
|
|
|
proc createFoo(): Foo = Foo(boo: 0)
|
|
|
|
proc test(): auto =
|
|
var a, b = createFoo()
|
|
return (a, b, Foo(boo: 5))
|
|
|
|
var (ag, bg, _) = test()
|
|
|
|
doAssert assign_counter == 0
|
|
doAssert sink_counter == 0
|
|
|
|
# bug #11510
|
|
proc main =
|
|
for i in 0 ..< 4:
|
|
var buffer: seq[int] # = @[] # uncomment to make it work
|
|
# var buffer: string # also this is broken
|
|
buffer.add i
|
|
echo buffer
|
|
|
|
main()
|