summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semexprs.nim4
-rw-r--r--compiler/semgnrc.nim8
-rw-r--r--testament/important_packages.nim3
-rw-r--r--tests/generics/mdotlookup.nim4
-rw-r--r--tests/generics/timports.nim2
5 files changed, 17 insertions, 4 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 4dd7840f1..b79abadff 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -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])
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim
index 01146bb7c..7dec8a30d 100644
--- a/compiler/semgnrc.nim
+++ b/compiler/semgnrc.nim
@@ -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:
diff --git a/testament/important_packages.nim b/testament/important_packages.nim
index d5a3ba97b..4c93189f1 100644
--- a/testament/important_packages.nim
+++ b/testament/important_packages.nim
@@ -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
diff --git a/tests/generics/mdotlookup.nim b/tests/generics/mdotlookup.nim
index b69a56daf..215f75003 100644
--- a/tests/generics/mdotlookup.nim
+++ b/tests/generics/mdotlookup.nim
@@ -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
diff --git a/tests/generics/timports.nim b/tests/generics/timports.nim
index b619c48cf..df830c1f0 100644
--- a/tests/generics/timports.nim
+++ b/tests/generics/timports.nim
@@ -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