mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 11:42:33 +00:00
@@ -274,7 +274,7 @@ proc matchSym(c: PContext; candidate: PSym, n: PNode; m: var MatchCon): bool =
|
||||
proc matchSyms(c: PContext, n: PNode; kinds: set[TSymKind]; m: var MatchCon): bool =
|
||||
## Walk the current scope, extract candidates which the same name as 'n[namePos]',
|
||||
## 'n' is the nkProcDef or similar from the concept that we try to match.
|
||||
let candidates = searchInScopesFilterBy(c, n[namePos].sym.name, kinds)
|
||||
let candidates = searchInScopesAllCandidatesFilterBy(c, n[namePos].sym.name, kinds)
|
||||
for candidate in candidates:
|
||||
#echo "considering ", typeToString(candidate.typ), " ", candidate.magic
|
||||
m.magic = candidate.magic
|
||||
|
||||
@@ -228,6 +228,23 @@ proc debugScopes*(c: PContext; limit=0, max = int.high) {.deprecated.} =
|
||||
if i == limit: return
|
||||
inc i
|
||||
|
||||
proc searchInScopesAllCandidatesFilterBy*(c: PContext, s: PIdent, filter: TSymKinds): seq[PSym] =
|
||||
result = @[]
|
||||
for scope in allScopes(c.currentScope):
|
||||
var ti: TIdentIter
|
||||
var candidate = initIdentIter(ti, scope.symbols, s)
|
||||
while candidate != nil:
|
||||
if candidate.kind in filter:
|
||||
result.add candidate
|
||||
candidate = nextIdentIter(ti, scope.symbols)
|
||||
|
||||
if result.len == 0:
|
||||
var marked = initIntSet()
|
||||
for im in c.imports.mitems:
|
||||
for s in symbols(im, marked, s, c.graph):
|
||||
if s.kind in filter:
|
||||
result.add s
|
||||
|
||||
proc searchInScopesFilterBy*(c: PContext, s: PIdent, filter: TSymKinds): seq[PSym] =
|
||||
result = @[]
|
||||
block outer:
|
||||
|
||||
@@ -27,6 +27,8 @@ false
|
||||
true
|
||||
-1
|
||||
Meow
|
||||
10 0.0
|
||||
1 2.0
|
||||
'''
|
||||
joinable: false
|
||||
"""
|
||||
@@ -500,3 +502,26 @@ var r, b: Fp2[6, uint64]
|
||||
|
||||
prod(r, b)
|
||||
|
||||
|
||||
block: # bug #21263
|
||||
type
|
||||
DateDayFraction = concept # no T, an atom
|
||||
proc date(a: Self): int
|
||||
proc fraction(b: Self): float
|
||||
Date = distinct int
|
||||
DateDayFractionImpl = object
|
||||
date : int
|
||||
fraction : float
|
||||
|
||||
proc date(a: Date): int = a.int
|
||||
proc fraction(a:Date): float = 0.0
|
||||
|
||||
proc date(a: DateDayFractionImpl): int = a.date
|
||||
proc fraction(b: DateDayFractionImpl): float = b.fraction
|
||||
|
||||
|
||||
proc print(a: DateDayFraction) =
|
||||
echo a.date, " ", a.fraction
|
||||
|
||||
print(10.Date) # ok
|
||||
print(DateDayFractionImpl(date: 1, fraction: 2)) # error
|
||||
|
||||
Reference in New Issue
Block a user