Skip to content

Commit

Permalink
fix subscript magic giving unresolved generic param type
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Aug 20, 2024
1 parent 43274bf commit ad73ad9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/semcall.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.} =
Expand Down
10 changes: 10 additions & 0 deletions tests/overload/m19737.nim
Original file line number Diff line number Diff line change
@@ -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))
15 changes: 15 additions & 0 deletions tests/overload/t19737.nim
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit ad73ad9

Please sign in to comment.