summary refs log tree commit diff stats
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2023-04-17 21:56:11 +0300
committerGitHub <noreply@github.com>2023-04-17 20:56:11 +0200
commit202b1904733845a8015acc36738b9413f78b3cbe (patch)
tree76bfa68d43f9f204b24b70d09fa6670ee00b103d
parentb0a98cc01e14a33d75866c10c290f63031dc2112 (diff)
downloadNim-202b1904733845a8015acc36738b9413f78b3cbe.tar.gz
revert #21227 (#21681)
* revert #21227 but keep test

* add test for #21677

* don't export

* delete test
-rw-r--r--compiler/sigmatch.nim8
-rw-r--r--tests/typerel/tint.nim4
-rw-r--r--tests/typerel/typedescs.nim15
3 files changed, 17 insertions, 10 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 92971b072..76c04e693 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -1849,9 +1849,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
       elif f.base.kind == tyNone:
         result = isGeneric
       else:
-        let r = typeRel(c, f.base, a.base, flags)
-        if r >= isIntConv:
-          result = r
+        result = typeRel(c, f.base, a.base, flags)
 
       if result != isNone:
         put(c, f, a)
@@ -1859,9 +1857,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
       if tfUnresolved in f.flags:
         result = typeRel(c, prev.base, a, flags)
       elif a.kind == tyTypeDesc:
-        let r = typeRel(c, prev.base, a.base, flags)
-        if r >= isIntConv:
-          result = r
+        result = typeRel(c, prev.base, a.base, flags)
       else:
         result = isNone
 
diff --git a/tests/typerel/tint.nim b/tests/typerel/tint.nim
deleted file mode 100644
index de0e78a81..000000000
--- a/tests/typerel/tint.nim
+++ /dev/null
@@ -1,4 +0,0 @@
-
-template a(T: type int32) = discard
-template a(T: type int64) = discard
-a(int)
diff --git a/tests/typerel/typedescs.nim b/tests/typerel/typedescs.nim
index 23b9ce64f..faf919e13 100644
--- a/tests/typerel/typedescs.nim
+++ b/tests/typerel/typedescs.nim
@@ -5,3 +5,18 @@ p(type((5, 6)))       # Compiles
 (type((5, 6))).p      # Doesn't compile (SIGSEGV: Illegal storage access.)
 type T = type((5, 6)) # Doesn't compile (SIGSEGV: Illegal storage access.)
 
+block: # issue #21677
+  type
+    Uints = uint16|uint32
+
+  template constructor(name: untyped, typ: typedesc[Uints], typ2: typedesc[Uints]) =
+    type
+      name = object
+        data: typ
+        data2: typ2
+
+    proc `init name`(data: typ, data2: typ2): name =
+      result.data = data
+      result.data2 = data2
+
+  constructor(Test, uint32, uint16)