mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 08:54:53 +00:00
resolve local symbols in generic type call RHS (#22610)
resolve local symbols in generic type call fixes #14509
This commit is contained in:
@@ -1995,6 +1995,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||
result = semTypeExpr(c, n[1], prev)
|
||||
else:
|
||||
if c.inGenericContext > 0 and n.kind == nkCall:
|
||||
let n = semGenericStmt(c, n)
|
||||
result = makeTypeFromExpr(c, n.copyTree)
|
||||
else:
|
||||
result = semTypeExpr(c, n, prev)
|
||||
|
||||
16
tests/generics/m14509.nim
Normal file
16
tests/generics/m14509.nim
Normal file
@@ -0,0 +1,16 @@
|
||||
import macros
|
||||
|
||||
type float32x4 = array[4, float32]
|
||||
type float32x8 = array[8, float32]
|
||||
|
||||
{.experimental: "dynamicBindSym".}
|
||||
macro dispatch(N: static int, T: type SomeNumber): untyped =
|
||||
let BaseT = getTypeInst(T)[1]
|
||||
result = bindSym($BaseT & "x" & $N)
|
||||
|
||||
type
|
||||
VecIntrin*[N: static int, T: SomeNumber] = dispatch(N, T)
|
||||
|
||||
func `$`*[N, T](vec: VecIntrin[N, T]): string =
|
||||
## Display a vector
|
||||
$cast[array[N, T]](vec)
|
||||
4
tests/generics/t14509.nim
Normal file
4
tests/generics/t14509.nim
Normal file
@@ -0,0 +1,4 @@
|
||||
import m14509
|
||||
|
||||
var v: VecIntrin[4, float32]
|
||||
doAssert $v == "[0.0, 0.0, 0.0, 0.0]"
|
||||
Reference in New Issue
Block a user