summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-12-17 21:52:01 +0100
committerAraq <rumpf_a@web.de>2014-12-17 21:52:01 +0100
commit73dda8a81de81d94adda004e1c346fcc7b040cb2 (patch)
tree61ecb1185aff36bbe097392c69e49711c8cec66c
parentb94d2247c833cf5ba6192b8914bad63793f0bbbb (diff)
downloadNim-73dda8a81de81d94adda004e1c346fcc7b040cb2.tar.gz
fixes #1638
-rw-r--r--compiler/semfold.nim8
-rw-r--r--tests/misc/teventemitter.nim8
-rw-r--r--tests/misc/tunsigned64mod.nim12
-rw-r--r--tests/testament/categories.nim4
4 files changed, 23 insertions, 9 deletions
diff --git a/compiler/semfold.nim b/compiler/semfold.nim
index c7ae42548..220abcad7 100644
--- a/compiler/semfold.nim
+++ b/compiler/semfold.nim
@@ -197,18 +197,20 @@ proc getIntervalType*(m: TMagic, n: PNode): PType =
   of mSubI, mSubI64, mSubU:
     binaryOp(`|-|`)
   of mBitandI, mBitandI64:
+    # since uint64 is still not even valid for 'range' (since it's no ordinal
+    # yet), we exclude it from the list (see bug #1638) for now:
     var a = n.sons[1]
     var b = n.sons[2]
     # symmetrical:
-    if b.kind notin {nkIntLit..nkUInt64Lit}: swap(a, b)
-    if b.kind in {nkIntLit..nkUInt64Lit}:
+    if b.kind notin {nkIntLit..nkUInt32Lit}: swap(a, b)
+    if b.kind in {nkIntLit..nkUInt32Lit}:
       let x = b.intVal|+|1
       if (x and -x) == x and x >= 0:
         result = makeRange(a.typ, 0, b.intVal)
   of mModU:
     let a = n.sons[1]
     let b = n.sons[2]
-    if b.kind in {nkIntLit..nkUInt64Lit}:
+    if b.kind in {nkIntLit..nkUInt32Lit}:
       if b.intVal >= 0:
         result = makeRange(a.typ, 0, b.intVal-1)
       else:
diff --git a/tests/misc/teventemitter.nim b/tests/misc/teventemitter.nim
index bfcf95701..c1cc3d3a9 100644
--- a/tests/misc/teventemitter.nim
+++ b/tests/misc/teventemitter.nim
@@ -10,15 +10,15 @@ type
     events*: Table[string, DoublyLinkedList[proc(e: EventArgs) {.nimcall.}]]
 
 proc emit*(emitter: EventEmitter, event: string, args: EventArgs) =
-  for func in nodes(emitter.events[event]):
-    func.value(args) #call function with args.
+  for fn in nodes(emitter.events[event]):
+    fn.value(args) #call function with args.
 
 proc on*(emitter: var EventEmitter, event: string, 
-         func: proc(e: EventArgs) {.nimcall.}) =
+         fn: proc(e: EventArgs) {.nimcall.}) =
   if not hasKey(emitter.events, event):
     var list: DoublyLinkedList[proc(e: EventArgs) {.nimcall.}]
     add(emitter.events, event, list) #if not, add it.
-  append(emitter.events.mget(event), func)
+  append(emitter.events.mget(event), fn)
 
 proc initEmitter(emitter: var EventEmitter) =
   emitter.events = initTable[string, 
diff --git a/tests/misc/tunsigned64mod.nim b/tests/misc/tunsigned64mod.nim
new file mode 100644
index 000000000..9ae0d535a
--- /dev/null
+++ b/tests/misc/tunsigned64mod.nim
@@ -0,0 +1,12 @@
+
+# bug #1638
+
+import unsigned
+
+let v1 = 7
+let v2 = 7'u64
+
+let t1 = v1 mod 2 # works
+let t2 = 7'u64 mod 2'u64 # works
+let t3 = v2 mod 2'u64 # Error: invalid type: 'range 0..1(uint64)
+let t4 = (v2 mod 2'u64).uint64 # works
diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim
index 566a74cab..ae9905cde 100644
--- a/tests/testament/categories.nim
+++ b/tests/testament/categories.nim
@@ -312,7 +312,7 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) =
 
 # ----------------------------------------------------------------------------
 
-const AdditionalCategories = ["debugger", "examples", "stdlib", "babel-core"]
+const AdditionalCategories = ["debugger", "examples", "lib", "babel-core"]
 
 proc `&.?`(a, b: string): string =
   # candidate for the stdlib?
@@ -342,7 +342,7 @@ proc processCategory(r: var TResults, cat: Category, options: string) =
     threadTests r, cat, options & " --threads:on"
   of "io":
     ioTests r, cat, options
-  of "stdlib":
+  of "lib":
     testStdlib(r, "lib/pure/*.nim", options, cat)
     testStdlib(r, "lib/packages/docutils/highlite", options, cat)
   of "examples":