diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2020-07-28 19:18:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-28 19:18:46 +0200 |
commit | 86c9b7833917cd3deac912488e4dc18a1ca1223a (patch) | |
tree | 0d6fc12157c4cf9a23f38f5133cc49b1e0891400 | |
parent | e4e4931432fbc81b1ced68b351691228fae31d36 (diff) | |
download | Nim-86c9b7833917cd3deac912488e4dc18a1ca1223a.tar.gz |
disable sink inference, only enable it for the stdlib. Reason: better source code compatibility (#15105)
-rw-r--r-- | changelog.md | 4 | ||||
-rw-r--r-- | compiler/options.nim | 2 | ||||
-rw-r--r-- | doc/destructors.rst | 12 | ||||
-rw-r--r-- | lib/system/inclrtl.nim | 3 | ||||
-rw-r--r-- | tests/arc/nim.cfg | 1 | ||||
-rw-r--r-- | tests/destructor/nim.cfg | 1 |
6 files changed, 18 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md index d4161373c..93c0797d3 100644 --- a/changelog.md +++ b/changelog.md @@ -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 diff --git a/compiler/options.nim b/compiler/options.nim index 5d9bc245b..7beabe5e8 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -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} diff --git a/doc/destructors.rst b/doc/destructors.rst index c97b17d6f..b433c38d7 100644 --- a/doc/destructors.rst +++ b/doc/destructors.rst @@ -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. diff --git a/lib/system/inclrtl.nim b/lib/system/inclrtl.nim index 4193f2bdd..d80980c72 100644 --- a/lib/system/inclrtl.nim +++ b/lib/system/inclrtl.nim @@ -48,3 +48,6 @@ when defined(nimlocks): {.pragma: benign, gcsafe, locks: 0.} else: {.pragma: benign, gcsafe.} + +when defined(nimHasSinkInference): + {.push sinkInference: on.} diff --git a/tests/arc/nim.cfg b/tests/arc/nim.cfg new file mode 100644 index 000000000..7c148b797 --- /dev/null +++ b/tests/arc/nim.cfg @@ -0,0 +1 @@ +--sinkInference:on diff --git a/tests/destructor/nim.cfg b/tests/destructor/nim.cfg new file mode 100644 index 000000000..7c148b797 --- /dev/null +++ b/tests/destructor/nim.cfg @@ -0,0 +1 @@ +--sinkInference:on |