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 #14254 #21837

Merged
merged 3 commits into from
May 20, 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
4 changes: 3 additions & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,9 @@ proc builtinFieldAccess(c: PContext; n: PNode; flags: var TExprFlags): PNode =
flags.incl efCannotBeDotCall

proc dotTransformation(c: PContext, n: PNode): PNode =
if isSymChoice(n[1]):
if isSymChoice(n[1]) or
# generics usually leave field names as symchoices, but not types
(n[1].kind == nkSym and n[1].sym.kind == skType):
result = newNodeI(nkDotCall, n.info)
result.add n[1]
result.add copyTree(n[0])
Expand Down
8 changes: 6 additions & 2 deletions compiler/semgnrc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,16 @@ proc fuzzyLookup(c: PContext, n: PNode, flags: TSemGenericFlags,
result = n
let n = n[1]
let ident = considerQuotedIdent(c, n)
var candidates = searchInScopesFilterBy(c, ident, routineKinds)
var candidates = searchInScopesFilterBy(c, ident, routineKinds+{skType})
# skType here because could be type conversion
if candidates.len > 0:
let s = candidates[0] # XXX take into account the other candidates!
isMacro = s.kind in {skTemplate, skMacro}
if withinBind in flags or s.id in ctx.toBind:
result = newDot(result, symChoice(c, n, s, scClosed))
if s.kind == skType: # don't put types in sym choice
result = newDot(result, semGenericStmtSymbol(c, n, s, ctx, flags, fromDotExpr=true))
else:
result = newDot(result, symChoice(c, n, s, scClosed))
elif s.isMixedIn:
result = newDot(result, symChoice(c, n, s, scForceOpen))
else:
Expand Down
3 changes: 2 additions & 1 deletion testament/important_packages.nim
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ pkg "measuremancer", "nimble testDeps; nimble -y test"
pkg "memo"
pkg "msgpack4nim", "nim c -r tests/test_spec.nim"
pkg "nake", "nim c nakefile.nim"
pkg "neo", "nim c -d:blas=openblas --mm:refc tests/all.nim"
pkg "neo", "nim c -d:blas=openblas --mm:refc tests/all.nim", "https://github.com/metagn/neo"
# remove custom url when https://github.com/andreaferretti/neo/pull/53 is merged
pkg "nesm", "nimble tests", "https://github.com/nim-lang/NESM", useHead = true
pkg "netty"
pkg "nico", allowFailure = true
Expand Down
4 changes: 4 additions & 0 deletions tests/generics/mdotlookup.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ import strutils

proc doStrip*[T](a: T): string =
result = ($a).strip()

type Foo = int32
proc baz2*[T](y: int): auto =
result = y.Foo
2 changes: 2 additions & 0 deletions tests/generics/timports.nim
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ block tdotlookup:
# bug #1444
fn(4)
doAssert doStrip(123) == "123"
# bug #14254
doAssert baz2[float](1'i8) == 1

block tmodule_same_as_proc:
# bug #1965
Expand Down