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:
Andreas Rumpf 2020-03-04 14:28:53 +01:00 • committed by GitHub
commit a0eca75182
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 158 additions and 28 deletions

View file

@ -256,6 +256,23 @@ An implementation is allowed, but not required to implement even more move
optimizations (and the current implementation does not).
Sink parameter inference
========================
The current implementation does a limited form of sink parameter
inference. The `.nosinks`:idx: pragma can be used to disable this inference
for a single routine:
.. code-block:: nim
proc addX(x: T; child: T) {.nosinks.} =
x.s.add child
To disable it for a section of code, one can
use `{.push sinkInference: off.}`...`{.pop.}`.
The details of the inference algorithm are currently undocumented.
Rewrite rules
=============