[minor] break loops if it is ambiguous (#18745)

* [minor] break loops if it is ambiguous

* Update compiler/lookups.nim

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>

Co-authored-by: Timothee Cour <timothee.cour2@gmail.com>
This commit is contained in:
flywind 2021-08-27 17:50:06 +08:00 • committed by GitHub
commit 5eba372570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -181,13 +181,14 @@ proc someSymFromImportTable*(c: PContext; name: PIdent; ambiguous: var bool): PS
if overloadableEnums notin c.features: if overloadableEnums notin c.features:
symSet.excl skEnumField symSet.excl skEnumField
result = nil result = nil
block outer:
for im in c.imports.mitems: for im in c.imports.mitems:
for s in symbols(im, marked, name, c.graph): for s in symbols(im, marked, name, c.graph):
if result == nil: if result == nil:
result = s result = s
else: elif s.kind notin symSet or result.kind notin symSet:
if s.kind notin symSet or result.kind notin symSet:
ambiguous = true ambiguous = true
break outer
proc searchInScopes*(c: PContext, s: PIdent; ambiguous: var bool): PSym = proc searchInScopes*(c: PContext, s: PIdent; ambiguous: var bool): PSym =
for scope in allScopes(c.currentScope): for scope in allScopes(c.currentScope):