mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-22 15:25:22 +00:00
Automatic dereferencing is removed (#20531)
This commit is contained in:
@@ -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"
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user