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

Draft
wants to merge 6 commits into
base: devel
Choose a base branch
from
Draft
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 @@ -1777,6 +1777,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
result = isGeneric
elif concpt.kind == tyConcept:
result = enterConceptMatch(c, f, x, flags)
elif x.kind == tyGenericBody and f[0] == x:
# not specific enough
result = isNone
else:
let genericBody = f[0]
var askip = skippedNone
Expand Down
4 changes: 3 additions & 1 deletion testament/important_packages.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ proc pkg(name: string; cmd = "nimble test -l"; url = "", useHead = true, allowFa

pkg "alea"
pkg "argparse"
pkg "arraymancer", "nimble install -y; nimble uninstall -i -y nimcuda; nimble install [email protected]; nim c tests/tests_cpu.nim"
pkg "arraymancer", "nimble install -y; nimble uninstall -i -y nimcuda; nimble install [email protected]; nim c tests/tests_cpu.nim",
# remove when https://github.com/mratsim/Arraymancer/pull/674 is merged
url = "https://github.com/metagn/Arraymancer"
pkg "ast_pattern_matching", "nim c -r tests/test1.nim"
pkg "asyncftpclient", "nimble compileExample"
pkg "asyncthreadpool", "nimble test --mm:refc"
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()