diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-03-04 14:28:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-04 14:28:53 +0100 |
commit | a0eca7518223a18f3633150de2c8d3c1c9e71560 (patch) | |
tree | 3a3a7690c066e214e073e2a9c2fd33a9876dc7eb /tests | |
parent | 614fb7567c80c3b071394714c3809c005aaad397 (diff) | |
download | Nim-a0eca7518223a18f3633150de2c8d3c1c9e71560.tar.gz |
sink parameter inference for types that have destructors (#13544)
* ensure capitalize doesn't take an inferred sink parameter * sink parameter inference: first version, for now disabled. Changed that sink parameters can be consumed multiple times in order to adhere to our spec. * sink inference can now be disabled with .nosinks; sometimes for proc type interop this is required * fixes yet another critical DFA bug * better implementation that also understands if expressions etc * document sink parameter inference and allow for global disabling
Diffstat (limited to 'tests')
-rw-r--r-- | tests/assert/tassert_c.nim | 4 | ||||
-rw-r--r-- | tests/destructor/tarc2.nim | 4 | ||||
-rw-r--r-- | tests/destructor/tconsume_twice.nim | 4 |
3 files changed, 8 insertions, 4 deletions
diff --git a/tests/assert/tassert_c.nim b/tests/assert/tassert_c.nim index 84ccea823..98b859c1c 100644 --- a/tests/assert/tassert_c.nim +++ b/tests/assert/tassert_c.nim @@ -6,8 +6,8 @@ discard """ const expected = """ tassert_c.nim(35) tassert_c tassert_c.nim(34) foo -assertions.nim(27) failedAssertImpl -assertions.nim(20) raiseAssert +assertions.nim(29) failedAssertImpl +assertions.nim(22) raiseAssert fatal.nim(55) sysFatal""" proc tmatch(x, p: string): bool = diff --git a/tests/destructor/tarc2.nim b/tests/destructor/tarc2.nim index bd6343b2f..7a683b4ba 100644 --- a/tests/destructor/tarc2.nim +++ b/tests/destructor/tarc2.nim @@ -13,9 +13,13 @@ proc create(): T = T(s: @[], data: "abc") proc addX(x: T; data: string) = x.data = data +{.push sinkInference: off.} + proc addX(x: T; child: T) = x.s.add child +{.pop.} + proc main(rootName: string) = var root = create() root.data = rootName diff --git a/tests/destructor/tconsume_twice.nim b/tests/destructor/tconsume_twice.nim index 8687b3ce5..0030267f8 100644 --- a/tests/destructor/tconsume_twice.nim +++ b/tests/destructor/tconsume_twice.nim @@ -1,7 +1,7 @@ discard """ cmd: "nim c --newruntime $file" - errormsg: "sink parameter `a` is already consumed at tconsume_twice.nim(11, 10)" - line: 13 + errormsg: "'=' is not available for type <owned Foo>; requires a copy because it's not the last read of 'a'; another read is done here: tconsume_twice.nim(13, 10); routine: consumeTwice" + line: 11 """ type Foo = ref object |