mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-10 23:15:02 +00:00
Fixed object field access of static objects in generics (#19283) [backport]
(cherry picked from commit fa96e56ad0)
This commit is contained in:
@@ -1414,7 +1414,7 @@ proc builtinFieldAccess(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
|
||||
if ty.kind in tyUserTypeClasses and ty.isResolvedUserTypeClass:
|
||||
ty = ty.lastSon
|
||||
ty = skipTypes(ty, {tyGenericInst, tyVar, tyLent, tyPtr, tyRef, tyOwned, tyAlias, tySink})
|
||||
ty = skipTypes(ty, {tyGenericInst, tyVar, tyLent, tyPtr, tyRef, tyOwned, tyAlias, tySink, tyStatic})
|
||||
while tfBorrowDot in ty.flags: ty = ty.skipTypes({tyDistinct, tyGenericInst, tyAlias})
|
||||
var check: PNode = nil
|
||||
if ty.kind == tyObject:
|
||||
|
||||
@@ -44,6 +44,14 @@ template main() =
|
||||
proc parseInt(f: static[bool]): int {.used.} = discard
|
||||
|
||||
doAssert "123".parseInt == 123
|
||||
block:
|
||||
type
|
||||
MyType = object
|
||||
field: float32
|
||||
AType[T: static MyType] = distinct range[0f32 .. T.field]
|
||||
var a: AType[MyType(field: 5f32)]
|
||||
proc n(S: static Slice[int]): range[S.a..S.b] = discard
|
||||
assert typeof(n 1..2) is range[1..2]
|
||||
|
||||
|
||||
static: main()
|
||||
|
||||
Reference in New Issue
Block a user