diff options
-rw-r--r-- | compiler/semcall.nim | 3 | ||||
-rw-r--r-- | tests/overload/m19737.nim | 10 | ||||
-rw-r--r-- | tests/overload/t19737.nim | 15 |
3 files changed, 27 insertions, 1 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim index 3981d256f..4240bc603 100644 --- a/compiler/semcall.nim +++ b/compiler/semcall.nim @@ -725,7 +725,8 @@ proc semResolvedCall(c: PContext, x: var TCandidate, result = x.call instGenericConvertersSons(c, result, x) result[0] = newSymNode(finalCallee, getCallLineInfo(result[0])) - result.typ = finalCallee.typ.returnType + if finalCallee.magic notin {mArrGet, mArrPut}: + result.typ = finalCallee.typ.returnType updateDefaultParams(result) proc canDeref(n: PNode): bool {.inline.} = diff --git a/tests/overload/m19737.nim b/tests/overload/m19737.nim new file mode 100644 index 000000000..7f7ac98e2 --- /dev/null +++ b/tests/overload/m19737.nim @@ -0,0 +1,10 @@ +type + UInt128* = object + lo, hi: uint64 + +func `<`*(x, y: UInt128): bool = + (x.hi < y.hi) or ((x.hi == y.hi) and (x.lo < y.lo)) + +when not defined(works): + func `>`*(x, y: UInt128): bool = + (x.hi > y.hi) or ((x.hi == y.hi) and (x.lo > y.lo)) diff --git a/tests/overload/t19737.nim b/tests/overload/t19737.nim new file mode 100644 index 000000000..b33ba9d8b --- /dev/null +++ b/tests/overload/t19737.nim @@ -0,0 +1,15 @@ +# issue #19737 + +import ./m19737 + +var m: seq[uint64] + +proc foo(x: bool) = discard + +proc test[T: uint64|uint32](s: var seq[T]) = + var tmp = newSeq[T](1) + s = newSeq[T](1) + + foo s[0] > tmp[0] + +test(m) |