summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/astalgo.nim14
-rw-r--r--tests/implicit/timplictderef.nim21
2 files changed, 26 insertions, 9 deletions
diff --git a/compiler/astalgo.nim b/compiler/astalgo.nim
index f23e9a983..e9b82d74b 100644
--- a/compiler/astalgo.nim
+++ b/compiler/astalgo.nim
@@ -130,8 +130,8 @@ proc skipConvAndClosure*(n: PNode): PNode =
 proc sameValue*(a, b: PNode): bool = 
   result = false
   case a.kind
-  of nkCharLit..nkInt64Lit: 
-    if b.kind in {nkCharLit..nkInt64Lit}: result = a.intVal == b.intVal
+  of nkCharLit..nkUInt64Lit: 
+    if b.kind in {nkCharLit..nkUInt64Lit}: result = a.intVal == b.intVal
   of nkFloatLit..nkFloat64Lit: 
     if b.kind in {nkFloatLit..nkFloat64Lit}: result = a.floatVal == b.floatVal
   of nkStrLit..nkTripleStrLit: 
@@ -145,13 +145,13 @@ proc leValue*(a, b: PNode): bool =
   # a <= b?
   result = false
   case a.kind
-  of nkCharLit..nkInt64Lit: 
-    if b.kind in {nkCharLit..nkInt64Lit}: result = a.intVal <= b.intVal
-  of nkFloatLit..nkFloat64Lit: 
+  of nkCharLit..nkUInt32Lit:
+    if b.kind in {nkCharLit..nkUInt32Lit}: result = a.intVal <= b.intVal
+  of nkFloatLit..nkFloat64Lit:
     if b.kind in {nkFloatLit..nkFloat64Lit}: result = a.floatVal <= b.floatVal
-  of nkStrLit..nkTripleStrLit: 
+  of nkStrLit..nkTripleStrLit:
     if b.kind in {nkStrLit..nkTripleStrLit}: result = a.strVal <= b.strVal
-  else: 
+  else:
     # don't raise an internal error for 'nimrod check':
     #InternalError(a.info, "leValue")
     discard
diff --git a/tests/implicit/timplictderef.nim b/tests/implicit/timplictderef.nim
index 99b0b645b..fcb647217 100644
--- a/tests/implicit/timplictderef.nim
+++ b/tests/implicit/timplictderef.nim
@@ -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[]