parent
30da566d9d
commit
cc08a9015e
3 changed files with 43 additions and 1 deletions
|
|
@ -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 =
|
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]',
|
## 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.
|
## '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:
|
for candidate in candidates:
|
||||||
#echo "considering ", typeToString(candidate.typ), " ", candidate.magic
|
#echo "considering ", typeToString(candidate.typ), " ", candidate.magic
|
||||||
m.magic = candidate.magic
|
m.magic = candidate.magic
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,23 @@ proc debugScopes*(c: PContext; limit=0, max = int.high) {.deprecated.} =
|
||||||
if i == limit: return
|
if i == limit: return
|
||||||
inc i
|
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] =
|
proc searchInScopesFilterBy*(c: PContext, s: PIdent, filter: TSymKinds): seq[PSym] =
|
||||||
result = @[]
|
result = @[]
|
||||||
block outer:
|
block outer:
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@ false
|
||||||
true
|
true
|
||||||
-1
|
-1
|
||||||
Meow
|
Meow
|
||||||
|
10 0.0
|
||||||
|
1 2.0
|
||||||
'''
|
'''
|
||||||
joinable: false
|
joinable: false
|
||||||
"""
|
"""
|
||||||
|
|
@ -500,3 +502,26 @@ var r, b: Fp2[6, uint64]
|
||||||
|
|
||||||
prod(r, b)
|
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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue