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

Fix #22826: Don't skip generic instances in type comparison #22828

Merged
merged 2 commits into from
Oct 21, 2023
Merged
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
8 changes: 4 additions & 4 deletions compiler/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1202,12 +1202,12 @@ proc sameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
if containsOrIncl(c, a, b): return true

if x == y: return true
var a = skipTypes(x, {tyGenericInst, tyAlias})
var a = skipTypes(x, {tyAlias})
while a.kind == tyUserTypeClass and tfResolved in a.flags:
a = skipTypes(a[^1], {tyGenericInst, tyAlias})
var b = skipTypes(y, {tyGenericInst, tyAlias})
a = skipTypes(a[^1], {tyAlias})
var b = skipTypes(y, {tyAlias})
while b.kind == tyUserTypeClass and tfResolved in b.flags:
b = skipTypes(b[^1], {tyGenericInst, tyAlias})
b = skipTypes(b[^1], {tyAlias})
assert(a != nil)
assert(b != nil)
if a.kind != b.kind:
Expand Down
8 changes: 8 additions & 0 deletions tests/generics/t22826.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import std/tables

var a: Table[string, float]

type Value*[T] = object
table: Table[string, Value[T]]

discard toTable({"a": Value[float]()})
Loading