mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-04 13:04:44 +00:00
unsigned array indexes work better; minor cleanups
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
discard """
|
||||
output: "2"
|
||||
output: '''2
|
||||
88'''
|
||||
"""
|
||||
|
||||
type
|
||||
TValue* {.pure, final.} = object of TObject
|
||||
TValue* {.pure, final.} = object of RootObj
|
||||
a: int
|
||||
PValue = ref TValue
|
||||
PPValue = ptr PValue
|
||||
@@ -16,3 +17,19 @@ 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[]
|
||||
|
||||
Reference in New Issue
Block a user