disable sink inference, only enable it for the stdlib. Reason: better source code compatibility (#15105)

This commit is contained in:
Andreas Rumpf
2020-07-28 19:18:46 +02:00
committed by GitHub
parent e4e4931432
commit 86c9b78339
6 changed files with 18 additions and 5 deletions

View File

@@ -265,6 +265,10 @@ proc mydiv(a, b): int {.raises: [].} =
- Removed the `--oldast` switch.
- `$getType(untyped)` is now "untyped" instead of "expr", `$getType(typed)` is
now "typed" instead of "stmt".
- Sink inference is now disabled per default and has to enabled explicitly via
`--sinkInference:on`. *Note*: For the standard library sink inference remains
enabled. This change is most relevant for the `--gc:arc`, `--gc:orc` memory
management modes.
## Tool changes

View File

@@ -373,7 +373,7 @@ const
DefaultOptions* = {optObjCheck, optFieldCheck, optRangeCheck,
optBoundsCheck, optOverflowCheck, optAssert, optWarns, optRefCheck,
optHints, optStackTrace, optLineTrace, # consider adding `optStackTraceMsgs`
optTrMacros, optStyleCheck, optSinkInference}
optTrMacros, optStyleCheck}
DefaultGlobalOptions* = {optThreadAnalysis,
optExcessiveStackTrace, optListFullPaths}

View File

@@ -261,8 +261,14 @@ 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
The current implementation can do a limited form of sink parameter
inference. But it has to be enabled via `--sinkInference:on`, either
on the command line or via a `push` pragma.
To enable it for a section of code, one can
use `{.push sinkInference: on.}`...`{.pop.}`.
The `.nosinks`:idx: pragma can be used to disable this inference
for a single routine:
.. code-block:: nim
@@ -270,8 +276,6 @@ for a single routine:
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.

View File

@@ -48,3 +48,6 @@ when defined(nimlocks):
{.pragma: benign, gcsafe, locks: 0.}
else:
{.pragma: benign, gcsafe.}
when defined(nimHasSinkInference):
{.push sinkInference: on.}

1
tests/arc/nim.cfg Normal file
View File

@@ -0,0 +1 @@
--sinkInference:on

1
tests/destructor/nim.cfg Normal file
View File

@@ -0,0 +1 @@
--sinkInference:on