fixes tcompiletimerange [bugfix] (#11720)
This commit is contained in:
parent
38b836b49e
commit
2895ad70c8
3 changed files with 29 additions and 7 deletions
|
|
@ -1379,8 +1379,11 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
||||||
if tx.isNil or isTupleRecursive(tx):
|
if tx.isNil or isTupleRecursive(tx):
|
||||||
localError(c.config, n.info, "illegal recursion in type '$1'" % typeToString(result[0]))
|
localError(c.config, n.info, "illegal recursion in type '$1'" % typeToString(result[0]))
|
||||||
return errorType(c)
|
return errorType(c)
|
||||||
if tx != result and tx.kind == tyObject and tx.sons[0] != nil:
|
if tx != result and tx.kind == tyObject:
|
||||||
semObjectTypeForInheritedGenericInst(c, n, tx)
|
if tx.sons[0] != nil:
|
||||||
|
semObjectTypeForInheritedGenericInst(c, n, tx)
|
||||||
|
var position = 0
|
||||||
|
recomputeFieldPositions(tx, tx.n, position)
|
||||||
|
|
||||||
proc maybeAliasType(c: PContext; typeExpr, prev: PType): PType =
|
proc maybeAliasType(c: PContext; typeExpr, prev: PType): PType =
|
||||||
if typeExpr.kind in {tyObject, tyEnum, tyDistinct, tyForward} and prev != nil:
|
if typeExpr.kind in {tyObject, tyEnum, tyDistinct, tyForward} and prev != nil:
|
||||||
|
|
|
||||||
|
|
@ -667,6 +667,22 @@ proc replaceTypesForLambda*(p: PContext, pt: TIdTable, n: PNode;
|
||||||
result = replaceTypeVarsN(cl, n)
|
result = replaceTypeVarsN(cl, n)
|
||||||
popInfoContext(p.config)
|
popInfoContext(p.config)
|
||||||
|
|
||||||
|
proc recomputeFieldPositions*(t: PType; obj: PNode; currPosition: var int) =
|
||||||
|
if t != nil and t.len > 0 and t.sons[0] != nil:
|
||||||
|
let b = skipTypes(t.sons[0], skipPtrs)
|
||||||
|
recomputeFieldPositions(b, b.n, currPosition)
|
||||||
|
case obj.kind
|
||||||
|
of nkRecList:
|
||||||
|
for i in 0 ..< sonsLen(obj): recomputeFieldPositions(nil, obj.sons[i], currPosition)
|
||||||
|
of nkRecCase:
|
||||||
|
recomputeFieldPositions(nil, obj.sons[0], currPosition)
|
||||||
|
for i in 1 ..< sonsLen(obj):
|
||||||
|
recomputeFieldPositions(nil, lastSon(obj.sons[i]), currPosition)
|
||||||
|
of nkSym:
|
||||||
|
obj.sym.position = currPosition
|
||||||
|
inc currPosition
|
||||||
|
else: discard "cannot happen"
|
||||||
|
|
||||||
proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,
|
proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,
|
||||||
t: PType): PType =
|
t: PType): PType =
|
||||||
var typeMap = initLayeredTypeMap(pt)
|
var typeMap = initLayeredTypeMap(pt)
|
||||||
|
|
@ -674,6 +690,10 @@ proc generateTypeInstance*(p: PContext, pt: TIdTable, info: TLineInfo,
|
||||||
pushInfoContext(p.config, info)
|
pushInfoContext(p.config, info)
|
||||||
result = replaceTypeVarsT(cl, t)
|
result = replaceTypeVarsT(cl, t)
|
||||||
popInfoContext(p.config)
|
popInfoContext(p.config)
|
||||||
|
let objType = result.skipTypes(abstractInst)
|
||||||
|
if objType.kind == tyObject:
|
||||||
|
var position = 0
|
||||||
|
recomputeFieldPositions(objType, objType.n, position)
|
||||||
|
|
||||||
proc prepareMetatypeForSigmatch*(p: PContext, pt: TIdTable, info: TLineInfo,
|
proc prepareMetatypeForSigmatch*(p: PContext, pt: TIdTable, info: TLineInfo,
|
||||||
t: PType): PType =
|
t: PType): PType =
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
discard """
|
discard """
|
||||||
disabled: "true"
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# issue #8199
|
# issue #8199
|
||||||
|
|
||||||
const rangesGCHoldEnabled = not defined(rangesDisableGCHold)
|
const rangesGCHoldEnabled = true # not defined(rangesDisableGCHold)
|
||||||
|
|
||||||
type
|
type
|
||||||
# A view into immutable array
|
# A view into immutable array
|
||||||
Range*[T] {.shallow.} = object
|
Range*[T] {.shallow.} = object
|
||||||
when rangesGCHoldEnabled:
|
when rangesGCHoldEnabled:
|
||||||
gcHold: seq[T]
|
gcHold: seq[T] # 0
|
||||||
start: ptr T
|
start: ptr T # 1
|
||||||
mLen: int32
|
mLen: int32 # 2
|
||||||
|
|
||||||
type
|
type
|
||||||
BytesRange* = Range[byte]
|
BytesRange* = Range[byte]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue