diff options
-rw-r--r-- | changelog.md | 2 | ||||
-rw-r--r-- | compiler/options.nim | 2 | ||||
-rw-r--r-- | compiler/semcall.nim | 21 | ||||
-rw-r--r-- | compiler/semexprs.nim | 6 | ||||
-rw-r--r-- | doc/manual.md | 4 | ||||
-rw-r--r-- | doc/manual_experimental.md | 23 | ||||
-rw-r--r-- | tests/implicit/timplicit.nim | 49 | ||||
-rw-r--r-- | tests/objects/tobject.nim | 15 |
8 files changed, 18 insertions, 104 deletions
diff --git a/changelog.md b/changelog.md index a95582fad..bcb5a6ba7 100644 --- a/changelog.md +++ b/changelog.md @@ -46,6 +46,8 @@ - Optional parameters in combination with `: body` syntax (RFC #405) are now opt-in via `experimental:flexibleOptionalParams`. +- Automatic dereferencing (experimental feature) is removed. + - The `Math.trunc` polyfill for targeting Internet Explorer was previously included in most JavaScript output files. Now, it is only included with `-d:nimJsMathTruncPolyfill`. diff --git a/compiler/options.nim b/compiler/options.nim index ce3b33355..1b352984f 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -195,7 +195,7 @@ type ideRecompile, ideChanged, ideType, ideDeclaration Feature* = enum ## experimental features; DO NOT RENAME THESE! - implicitDeref, + implicitDeref, # deadcode; remains here for backwards compatibility dotOperators, callOperator, parallel, diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 3dff744a3..cd009ce69 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -580,27 +580,6 @@ proc semOverloadedCall(c: PContext, n, nOrig: PNode, "Non-matching candidates for " & renderTree(n) & "\n" & candidates) result = semResolvedCall(c, r, n, flags) - elif implicitDeref in c.features and canDeref(n): - # try to deref the first argument and then try overloading resolution again: - # - # XXX: why is this here? - # it could be added to the long list of alternatives tried - # inside `resolveOverloads` or it could be moved all the way - # into sigmatch with hidden conversion produced there - # - n[1] = n[1].tryDeref - var r = resolveOverloads(c, n, nOrig, filter, flags, errors, efExplain in flags) - if r.state == csMatch: result = semResolvedCall(c, r, n, flags) - else: - # get rid of the deref again for a better error message: - n[1] = n[1][0] - #notFoundError(c, n, errors) - if efExplain notin flags: - # repeat the overload resolution, - # this time enabling all the diagnostic output (this should fail again) - discard semOverloadedCall(c, n, nOrig, filter, flags + {efExplain}) - elif efNoUndeclared notin flags: - notFoundError(c, n, errors) else: if efExplain notin flags: # repeat the overload resolution, diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index d4d197534..8c574e318 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -932,12 +932,6 @@ proc resolveIndirectCall(c: PContext; n, nOrig: PNode; t: PType): TCandidate = initCandidate(c, result, t) matches(c, n, nOrig, result) - if result.state != csMatch: - # try to deref the first argument: - if implicitDeref in c.features and canDeref(n): - n[1] = n[1].tryDeref - initCandidate(c, result, t) - matches(c, n, nOrig, result) proc bracketedMacro(n: PNode): PSym = if n.len >= 1 and n[0].kind == nkSym: diff --git a/doc/manual.md b/doc/manual.md index 41f6f0638..df486d446 100644 --- a/doc/manual.md +++ b/doc/manual.md @@ -1984,10 +1984,6 @@ dereferencing operations for reference types: # no need to write n[].data; in fact n[].data is highly discouraged! ``` -Automatic dereferencing can be performed for the first argument of a routine -call, but this is an experimental feature and is described [here]( -manual_experimental.html#automatic-dereferencing). - In order to simplify structural type checking, recursive tuples are not valid: ```nim diff --git a/doc/manual_experimental.md b/doc/manual_experimental.md index 5679db35a..cef4ff265 100644 --- a/doc/manual_experimental.md +++ b/doc/manual_experimental.md @@ -286,29 +286,6 @@ scope. Therefore, the following will *fail to compile:* This feature will likely be replaced with a better solution to remove the need for forward declarations. - -Automatic dereferencing -======================= - -Automatic dereferencing is performed for the first argument of a routine call. -This feature has to be enabled via `{.experimental: "implicitDeref".}`: - - ```nim - {.experimental: "implicitDeref".} - - type - NodeObj = object - # ... - Node = ref NodeObj - - proc depth(x: NodeObj): int = ... - - let n = Node() - echo n.depth - # no need to write n[].depth - ``` - - Special Operators ================= diff --git a/tests/implicit/timplicit.nim b/tests/implicit/timplicit.nim deleted file mode 100644 index bb701249c..000000000 --- a/tests/implicit/timplicit.nim +++ /dev/null @@ -1,49 +0,0 @@ -discard """ - output: ''' -1 -2 -3 -4 -2 -88 -timplicit done -''' -""" - - -for x in [1, 2, 3, 4]: - echo x - - -type - TValue* {.pure, final.} = object of RootObj - a: int - PValue = ref TValue - PPValue = ptr PValue - - -var x: PValue -new x -var sp: PPValue = addr x - -sp.a = 2 -if sp.a == 2: echo 2 # with sp[].a the error is gone - -# Test the new auto-deref a little - -{.experimental.} - -proc p(x: var int; y: int) = x += y - -block: - var x: ref int - new(x) - - x.p(44) - - var indirect = p - x.indirect(44) - - echo x[] - - echo "timplicit done" diff --git a/tests/objects/tobject.nim b/tests/objects/tobject.nim index 207cda0bc..a185bebcb 100644 --- a/tests/objects/tobject.nim +++ b/tests/objects/tobject.nim @@ -57,3 +57,18 @@ block: # bug #14698 x1: int x3: seq[int] doAssert t[].sizeof == Foo1.sizeof + +# bug #147 +type + TValue* {.pure, final.} = object of RootObj + a: int + PValue = ref TValue + PPValue = ptr PValue + + +var x: PValue +new x +var sp: PPValue = addr x + +sp.a = 2 +doAssert sp.a == 2 |