summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/sigmatch.nim2
-rw-r--r--tests/typerel/t7734.nim19
2 files changed, 20 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 523783b36..f9d1edc89 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -1425,7 +1425,7 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
 
   of tyGenericBody:
     considerPreviousT:
-      if a.kind == tyGenericInst and a.sons[0] == f:
+      if a == f or a.kind == tyGenericInst and a.sons[0] == f:
         bindingRet isGeneric
       let ff = lastSon(f)
       if ff != nil:
diff --git a/tests/typerel/t7734.nim b/tests/typerel/t7734.nim
new file mode 100644
index 000000000..1e8df2cf1
--- /dev/null
+++ b/tests/typerel/t7734.nim
@@ -0,0 +1,19 @@
+type
+  Foo[T: SomeFloat] = object
+    learning_rate: T
+
+  Bar[T: SomeFloat] = object
+    learning_rate: T
+    momentum: T
+
+  Model = object
+    weight: int
+
+  FooClass = Foo or Bar
+
+
+proc optimizer[M; T: SomeFloat](model: M, _: typedesc[Foo], learning_rate: T): Foo[T] =
+  result.learning_rate = learning_rate
+
+let a = Model(weight: 1)
+let opt = a.optimizer(Foo, 10.0)