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
This commit is contained in:
parent
614fb7567c
commit
a0eca75182
19 changed files with 158 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue