Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not match generic invocations to their base body types #24690

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
elif x.kind == tyGenericInst and concpt.kind == tyConcept:
result = if concepts.conceptMatch(c.c, concpt, x, c.bindings, f): isGeneric
else: isNone
elif x.kind == tyGenericBody and f[0] == x:
# not specific enough
result = isNone
else:
let genericBody = f[0]
var askip = skippedNone
Expand Down
3 changes: 2 additions & 1 deletion tests/generics/tgenerics_issues.nim
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,8 @@ block t1684:
block t5632:
type Option[T] = object

proc point[A](v: A, t: typedesc[Option[A]]): Option[A] =
# original issue test uses Option[A] instead
proc point[A](v: A, t: typedesc[Option]): Option[A] =
discard

discard point(1, Option)
Expand Down
13 changes: 13 additions & 0 deletions tests/overload/tgenericbodymatch.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# issue #24688

type
R[T, E] = object
A = object
B = object

# Remove this overload to make it work
func err[T](_: type R[T, void]): R[T, void] = discard

func err(_: type R): R[A, B] = discard

discard R.err()
Loading