Skip to content

Commit

Permalink
make new concepts match themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn committed Oct 5, 2024
1 parent 7dfadb8 commit d141c05
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/sigmatch.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1899,8 +1899,11 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
else:
result = isNone
of tyConcept:
result = if concepts.conceptMatch(c.c, f, a, c.bindings, nil): isGeneric
else: isNone
if a.kind == tyConcept and sameType(f, a):
result = isGeneric
else:
result = if concepts.conceptMatch(c.c, f, a, c.bindings, nil): isGeneric
else: isNone
of tyCompositeTypeClass:
considerPreviousT:
let roota = a.skipGenericAlias
Expand Down
22 changes: 22 additions & 0 deletions tests/concepts/tintypesection.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# issues with concepts in type section types

block: # issue #22839
type
Comparable = concept
proc `<`(a, b: Self): bool

# Works with this.
# Comparable = concept a
# `<`(a, a) is bool

# Doesn't work with the new style concept.
Node[T: Comparable] = object
data: T
next: ref Node[T]

var x: Node[int]
type NotComparable = object
doAssert not (compiles do:
var y: Node[NotComparable])
proc `<`(a, b: NotComparable): bool = false
var z: Node[NotComparable]

0 comments on commit d141c05

Please sign in to comment.