make some tests green
This commit is contained in:
parent
eebee0eff2
commit
5b0d8246f7
13 changed files with 98 additions and 77 deletions
|
|
@ -1054,7 +1054,7 @@ proc genSeqConstr(p: BProc, t: PNode, d: var TLoc) =
|
||||||
# generate call to newSeq before adding the elements per hand:
|
# generate call to newSeq before adding the elements per hand:
|
||||||
genNewSeqAux(p, d, intLiteral(sonsLen(t)))
|
genNewSeqAux(p, d, intLiteral(sonsLen(t)))
|
||||||
for i in countup(0, sonsLen(t) - 1):
|
for i in countup(0, sonsLen(t) - 1):
|
||||||
initLoc(arr, locExpr, elemType(skipTypes(t.typ, abstractInst)), OnHeap)
|
initLoc(arr, locExpr, elemType(skipTypes(t.typ, typedescInst)), OnHeap)
|
||||||
arr.r = rfmt(nil, "$1->data[$2]", rdLoc(d), intLiteral(i))
|
arr.r = rfmt(nil, "$1->data[$2]", rdLoc(d), intLiteral(i))
|
||||||
arr.s = OnHeap # we know that sequences are on the heap
|
arr.s = OnHeap # we know that sequences are on the heap
|
||||||
expr(p, t.sons[i], arr)
|
expr(p, t.sons[i], arr)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ proc genTraverseProc(c: var TTraversalClosure, accessor: PRope, typ: PType) =
|
||||||
if typ == nil: return
|
if typ == nil: return
|
||||||
var p = c.p
|
var p = c.p
|
||||||
case typ.kind
|
case typ.kind
|
||||||
of tyGenericInst, tyGenericBody:
|
of tyGenericInst, tyGenericBody, tyTypeDesc:
|
||||||
genTraverseProc(c, accessor, lastSon(typ))
|
genTraverseProc(c, accessor, lastSon(typ))
|
||||||
of tyArrayConstr, tyArray:
|
of tyArrayConstr, tyArray:
|
||||||
let arraySize = lengthOrd(typ.sons[0])
|
let arraySize = lengthOrd(typ.sons[0])
|
||||||
|
|
@ -111,10 +111,11 @@ proc genTraverseProc(m: BModule, typ: PType, reason: TTypeInfoReason): PRope =
|
||||||
lineF(p, cpsInit, "a = ($1)p;$n", t)
|
lineF(p, cpsInit, "a = ($1)p;$n", t)
|
||||||
|
|
||||||
c.p = p
|
c.p = p
|
||||||
|
assert typ.kind != tyTypedesc
|
||||||
if typ.kind == tySequence:
|
if typ.kind == tySequence:
|
||||||
genTraverseProcSeq(c, "a".toRope, typ)
|
genTraverseProcSeq(c, "a".toRope, typ)
|
||||||
else:
|
else:
|
||||||
if skipTypes(typ.sons[0], abstractInst).kind in {tyArrayConstr, tyArray}:
|
if skipTypes(typ.sons[0], typedescInst).kind in {tyArrayConstr, tyArray}:
|
||||||
# C's arrays are broken beyond repair:
|
# C's arrays are broken beyond repair:
|
||||||
genTraverseProc(c, "a".toRope, typ.sons[0])
|
genTraverseProc(c, "a".toRope, typ.sons[0])
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -193,8 +193,8 @@ proc mapType(typ: PType): TCTypeKind =
|
||||||
of 8: result = ctInt64
|
of 8: result = ctInt64
|
||||||
else: internalError("mapType")
|
else: internalError("mapType")
|
||||||
of tyRange: result = mapType(typ.sons[0])
|
of tyRange: result = mapType(typ.sons[0])
|
||||||
of tyPtr, tyVar, tyRef:
|
of tyPtr, tyVar, tyRef:
|
||||||
var base = skipTypes(typ.sons[0], abstractInst)
|
var base = skipTypes(typ.sons[0], typedescInst)
|
||||||
case base.kind
|
case base.kind
|
||||||
of tyOpenArray, tyArrayConstr, tyArray, tyVarargs: result = ctArray
|
of tyOpenArray, tyArrayConstr, tyArray, tyVarargs: result = ctArray
|
||||||
else: result = ctPtr
|
else: result = ctPtr
|
||||||
|
|
@ -208,7 +208,7 @@ proc mapType(typ: PType): TCTypeKind =
|
||||||
else: InternalError("mapType")
|
else: InternalError("mapType")
|
||||||
|
|
||||||
proc mapReturnType(typ: PType): TCTypeKind =
|
proc mapReturnType(typ: PType): TCTypeKind =
|
||||||
if skipTypes(typ, abstractInst).kind == tyArray: result = ctPtr
|
if skipTypes(typ, typedescInst).kind == tyArray: result = ctPtr
|
||||||
else: result = mapType(typ)
|
else: result = mapType(typ)
|
||||||
|
|
||||||
proc getTypeDescAux(m: BModule, typ: PType, check: var TIntSet): PRope
|
proc getTypeDescAux(m: BModule, typ: PType, check: var TIntSet): PRope
|
||||||
|
|
@ -224,10 +224,10 @@ proc isInvalidReturnType(rettype: PType): bool =
|
||||||
else:
|
else:
|
||||||
case mapType(rettype)
|
case mapType(rettype)
|
||||||
of ctArray:
|
of ctArray:
|
||||||
result = not (skipTypes(rettype, abstractInst).kind in
|
result = not (skipTypes(rettype, typedescInst).kind in
|
||||||
{tyVar, tyRef, tyPtr})
|
{tyVar, tyRef, tyPtr})
|
||||||
of ctStruct:
|
of ctStruct:
|
||||||
result = needsComplexAssignment(skipTypes(rettype, abstractInst))
|
result = needsComplexAssignment(skipTypes(rettype, typedescInst))
|
||||||
else: result = false
|
else: result = false
|
||||||
|
|
||||||
const
|
const
|
||||||
|
|
@ -253,7 +253,7 @@ proc getGlobalTempName(): PRope =
|
||||||
result = rfmt(nil, "TMP$1", toRope(backendId()))
|
result = rfmt(nil, "TMP$1", toRope(backendId()))
|
||||||
|
|
||||||
proc ccgIntroducedPtr(s: PSym): bool =
|
proc ccgIntroducedPtr(s: PSym): bool =
|
||||||
var pt = skipTypes(s.typ, abstractInst)
|
var pt = skipTypes(s.typ, typedescInst)
|
||||||
assert skResult != s.kind
|
assert skResult != s.kind
|
||||||
if tfByRef in pt.flags: return true
|
if tfByRef in pt.flags: return true
|
||||||
elif tfByCopy in pt.flags: return false
|
elif tfByCopy in pt.flags: return false
|
||||||
|
|
@ -280,13 +280,13 @@ proc fillResult(param: PSym) =
|
||||||
proc getParamTypeDesc(m: BModule, t: PType, check: var TIntSet): PRope =
|
proc getParamTypeDesc(m: BModule, t: PType, check: var TIntSet): PRope =
|
||||||
when false:
|
when false:
|
||||||
if t.Kind in {tyRef, tyPtr, tyVar}:
|
if t.Kind in {tyRef, tyPtr, tyVar}:
|
||||||
var b = skipTypes(t.sons[0], abstractInst)
|
var b = skipTypes(t.sons[0], typedescInst)
|
||||||
if b.kind == tySet and mapSetType(b) == ctArray:
|
if b.kind == tySet and mapSetType(b) == ctArray:
|
||||||
return getTypeDescAux(m, b, check)
|
return getTypeDescAux(m, b, check)
|
||||||
result = getTypeDescAux(m, t, check)
|
result = getTypeDescAux(m, t, check)
|
||||||
|
|
||||||
proc paramStorageLoc(param: PSym): TStorageLoc =
|
proc paramStorageLoc(param: PSym): TStorageLoc =
|
||||||
if param.typ.skipTypes({tyVar}).kind notin {tyArray, tyOpenArray}:
|
if param.typ.skipTypes({tyVar, tyTypeDesc}).kind notin {tyArray, tyOpenArray}:
|
||||||
result = OnStack
|
result = OnStack
|
||||||
else:
|
else:
|
||||||
result = OnUnknown
|
result = OnUnknown
|
||||||
|
|
@ -572,7 +572,7 @@ proc getTypeDescAux(m: BModule, typ: PType, check: var TIntSet): PRope =
|
||||||
assert(CacheGetType(m.typeCache, t) == nil)
|
assert(CacheGetType(m.typeCache, t) == nil)
|
||||||
IdTablePut(m.typeCache, t, con(result, "*"))
|
IdTablePut(m.typeCache, t, con(result, "*"))
|
||||||
if not isImportedType(t):
|
if not isImportedType(t):
|
||||||
if skipTypes(t.sons[0], abstractInst).kind != tyEmpty:
|
if skipTypes(t.sons[0], typedescInst).kind != tyEmpty:
|
||||||
const
|
const
|
||||||
cppSeq = "struct $2 : #TGenericSeq {$n"
|
cppSeq = "struct $2 : #TGenericSeq {$n"
|
||||||
cSeq = "struct $2 {$n" &
|
cSeq = "struct $2 {$n" &
|
||||||
|
|
@ -915,7 +915,7 @@ include ccgtrav
|
||||||
proc genTypeInfo(m: BModule, typ: PType): PRope =
|
proc genTypeInfo(m: BModule, typ: PType): PRope =
|
||||||
var t = getUniqueType(typ)
|
var t = getUniqueType(typ)
|
||||||
result = ropef("NTI$1", [toRope(t.id)])
|
result = ropef("NTI$1", [toRope(t.id)])
|
||||||
let owner = typ.skipTypes(abstractPtrs).owner.getModule
|
let owner = typ.skipTypes(typedescPtrs).owner.getModule
|
||||||
if owner != m.module:
|
if owner != m.module:
|
||||||
# make sure the type info is created in the owner module
|
# make sure the type info is created in the owner module
|
||||||
discard genTypeInfo(owner.bmod, typ)
|
discard genTypeInfo(owner.bmod, typ)
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ proc GetUniqueType*(key: PType): PType =
|
||||||
# no canonicalization for integral types, so that e.g. ``pid_t`` is
|
# no canonicalization for integral types, so that e.g. ``pid_t`` is
|
||||||
# produced instead of ``NI``.
|
# produced instead of ``NI``.
|
||||||
result = key
|
result = key
|
||||||
of tyEmpty, tyNil, tyExpr, tyStmt, tyTypeDesc, tyPointer, tyString,
|
of tyEmpty, tyNil, tyExpr, tyStmt, tyPointer, tyString,
|
||||||
tyCString, tyNone, tyBigNum:
|
tyCString, tyNone, tyBigNum:
|
||||||
result = gCanonicalTypes[k]
|
result = gCanonicalTypes[k]
|
||||||
if result == nil:
|
if result == nil:
|
||||||
|
|
@ -88,7 +88,8 @@ proc GetUniqueType*(key: PType): PType =
|
||||||
result = key
|
result = key
|
||||||
of tyGenericParam, tyTypeClass:
|
of tyGenericParam, tyTypeClass:
|
||||||
InternalError("GetUniqueType")
|
InternalError("GetUniqueType")
|
||||||
of tyGenericInst, tyDistinct, tyOrdinal, tyMutable, tyConst, tyIter:
|
of tyGenericInst, tyDistinct, tyOrdinal, tyMutable, tyConst, tyIter,
|
||||||
|
tyTypeDesc:
|
||||||
result = GetUniqueType(lastSon(key))
|
result = GetUniqueType(lastSon(key))
|
||||||
of tyArrayConstr, tyGenericInvokation, tyGenericBody,
|
of tyArrayConstr, tyGenericInvokation, tyGenericBody,
|
||||||
tyOpenArray, tyArray, tySet, tyRange, tyTuple,
|
tyOpenArray, tyArray, tySet, tyRange, tyTuple,
|
||||||
|
|
|
||||||
|
|
@ -187,21 +187,24 @@ proc isAssignable*(owner: PSym, n: PNode): TAssignableResult =
|
||||||
else:
|
else:
|
||||||
result = arLValue
|
result = arLValue
|
||||||
of nkDotExpr:
|
of nkDotExpr:
|
||||||
if skipTypes(n.sons[0].typ, abstractInst).kind in {tyVar, tyPtr, tyRef}:
|
if skipTypes(n.sons[0].typ, abstractInst-{tyTypeDesc}).kind in
|
||||||
|
{tyVar, tyPtr, tyRef}:
|
||||||
result = arLValue
|
result = arLValue
|
||||||
else:
|
else:
|
||||||
result = isAssignable(owner, n.sons[0])
|
result = isAssignable(owner, n.sons[0])
|
||||||
if result != arNone and sfDiscriminant in n.sons[1].sym.flags:
|
if result != arNone and sfDiscriminant in n.sons[1].sym.flags:
|
||||||
result = arDiscriminant
|
result = arDiscriminant
|
||||||
of nkBracketExpr:
|
of nkBracketExpr:
|
||||||
if skipTypes(n.sons[0].typ, abstractInst).kind in {tyVar, tyPtr, tyRef}:
|
if skipTypes(n.sons[0].typ, abstractInst-{tyTypeDesc}).kind in
|
||||||
|
{tyVar, tyPtr, tyRef}:
|
||||||
result = arLValue
|
result = arLValue
|
||||||
else:
|
else:
|
||||||
result = isAssignable(owner, n.sons[0])
|
result = isAssignable(owner, n.sons[0])
|
||||||
of nkHiddenStdConv, nkHiddenSubConv, nkConv:
|
of nkHiddenStdConv, nkHiddenSubConv, nkConv:
|
||||||
# Object and tuple conversions are still addressable, so we skip them
|
# Object and tuple conversions are still addressable, so we skip them
|
||||||
# XXX why is 'tyOpenArray' allowed here?
|
# XXX why is 'tyOpenArray' allowed here?
|
||||||
if skipTypes(n.typ, abstractPtrs).kind in {tyOpenArray, tyTuple, tyObject}:
|
if skipTypes(n.typ, abstractPtrs-{tyTypeDesc}).kind in
|
||||||
|
{tyOpenArray, tyTuple, tyObject}:
|
||||||
result = isAssignable(owner, n.sons[1])
|
result = isAssignable(owner, n.sons[1])
|
||||||
elif compareTypes(n.typ, n.sons[1].typ, dcEqIgnoreDistinct):
|
elif compareTypes(n.typ, n.sons[1].typ, dcEqIgnoreDistinct):
|
||||||
# types that are equal modulo distinction preserve l-value:
|
# types that are equal modulo distinction preserve l-value:
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@ proc SearchForBorrowProc(c: PContext, fn: PSym, tos: int): PSym =
|
||||||
call.add(newIdentNode(fn.name, fn.info))
|
call.add(newIdentNode(fn.name, fn.info))
|
||||||
for i in 1.. <fn.typ.n.len:
|
for i in 1.. <fn.typ.n.len:
|
||||||
let param = fn.typ.n.sons[i]
|
let param = fn.typ.n.sons[i]
|
||||||
let t = skipTypes(param.typ, abstractVar)
|
let t = skipTypes(param.typ, abstractVar-{tyTypeDesc})
|
||||||
call.add(newNodeIT(nkEmpty, fn.info, t.baseOfDistinct))
|
call.add(newNodeIT(nkEmpty, fn.info, t.baseOfDistinct))
|
||||||
var resolved = semOverloadedCall(c, call, call, {fn.kind})
|
var resolved = semOverloadedCall(c, call, call, {fn.kind})
|
||||||
if resolved != nil:
|
if resolved != nil:
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
# included from sem.nim
|
# included from sem.nim
|
||||||
|
|
||||||
proc restoreOldStyleType(n: PNode) =
|
proc restoreOldStyleType(n: PNode) =
|
||||||
# XXX: semExprWithType used to return the same type
|
# semExprWithType used to return the same type
|
||||||
# for nodes such as (100) or (int).
|
# for nodes such as (100) or (int).
|
||||||
# This is inappropriate. The type of the first expression
|
# This is inappropriate. The type of the first expression
|
||||||
# should be "int", while the type of the second one should
|
# should be "int", while the type of the second one should
|
||||||
|
|
@ -75,7 +75,7 @@ proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
|
||||||
case s.kind
|
case s.kind
|
||||||
of skConst:
|
of skConst:
|
||||||
markUsed(n, s)
|
markUsed(n, s)
|
||||||
case skipTypes(s.typ, abstractInst).kind
|
case skipTypes(s.typ, abstractInst-{tyTypeDesc}).kind
|
||||||
of tyNil, tyChar, tyInt..tyInt64, tyFloat..tyFloat128,
|
of tyNil, tyChar, tyInt..tyInt64, tyFloat..tyFloat128,
|
||||||
tyTuple, tySet, tyUInt..tyUInt64:
|
tyTuple, tySet, tyUInt..tyUInt64:
|
||||||
result = inlineConst(n, s)
|
result = inlineConst(n, s)
|
||||||
|
|
@ -145,7 +145,7 @@ proc checkConvertible(castDest, src: PType): TConvStatus =
|
||||||
result = convNotNeedeed
|
result = convNotNeedeed
|
||||||
return
|
return
|
||||||
var d = skipTypes(castDest, abstractVar)
|
var d = skipTypes(castDest, abstractVar)
|
||||||
var s = skipTypes(src, abstractVar)
|
var s = skipTypes(src, abstractVar-{tyTypeDesc})
|
||||||
while (d != nil) and (d.Kind in {tyPtr, tyRef}) and (d.Kind == s.Kind):
|
while (d != nil) and (d.Kind in {tyPtr, tyRef}) and (d.Kind == s.Kind):
|
||||||
d = base(d)
|
d = base(d)
|
||||||
s = base(s)
|
s = base(s)
|
||||||
|
|
@ -154,7 +154,7 @@ proc checkConvertible(castDest, src: PType): TConvStatus =
|
||||||
elif d.Kind == tyObject and s.Kind == tyObject:
|
elif d.Kind == tyObject and s.Kind == tyObject:
|
||||||
result = checkConversionBetweenObjects(d, s)
|
result = checkConversionBetweenObjects(d, s)
|
||||||
elif (skipTypes(castDest, abstractVarRange).Kind in IntegralTypes) and
|
elif (skipTypes(castDest, abstractVarRange).Kind in IntegralTypes) and
|
||||||
(skipTypes(src, abstractVarRange).Kind in IntegralTypes):
|
(skipTypes(src, abstractVarRange-{tyTypeDesc}).Kind in IntegralTypes):
|
||||||
# accept conversion between integral types
|
# accept conversion between integral types
|
||||||
else:
|
else:
|
||||||
# we use d, s here to speed up that operation a bit:
|
# we use d, s here to speed up that operation a bit:
|
||||||
|
|
@ -181,7 +181,7 @@ proc isCastable(dst, src: PType): bool =
|
||||||
else:
|
else:
|
||||||
result = (ds >= ss) or
|
result = (ds >= ss) or
|
||||||
(skipTypes(dst, abstractInst).kind in IntegralTypes) or
|
(skipTypes(dst, abstractInst).kind in IntegralTypes) or
|
||||||
(skipTypes(src, abstractInst).kind in IntegralTypes)
|
(skipTypes(src, abstractInst-{tyTypeDesc}).kind in IntegralTypes)
|
||||||
|
|
||||||
proc isSymChoice(n: PNode): bool {.inline.} =
|
proc isSymChoice(n: PNode): bool {.inline.} =
|
||||||
result = n.kind in nkSymChoices
|
result = n.kind in nkSymChoices
|
||||||
|
|
@ -195,7 +195,7 @@ proc semConv(c: PContext, n: PNode, s: PSym): PNode =
|
||||||
addSon(result, copyTree(n.sons[0]))
|
addSon(result, copyTree(n.sons[0]))
|
||||||
addSon(result, semExprWithType(c, n.sons[1]))
|
addSon(result, semExprWithType(c, n.sons[1]))
|
||||||
var op = result.sons[1]
|
var op = result.sons[1]
|
||||||
|
|
||||||
if not isSymChoice(op):
|
if not isSymChoice(op):
|
||||||
let status = checkConvertible(result.typ, op.typ)
|
let status = checkConvertible(result.typ, op.typ)
|
||||||
case status
|
case status
|
||||||
|
|
@ -234,24 +234,24 @@ proc semLowHigh(c: PContext, n: PNode, m: TMagic): PNode =
|
||||||
LocalError(n.info, errXExpectsTypeOrValue, opToStr[m])
|
LocalError(n.info, errXExpectsTypeOrValue, opToStr[m])
|
||||||
else:
|
else:
|
||||||
n.sons[1] = semExprWithType(c, n.sons[1])
|
n.sons[1] = semExprWithType(c, n.sons[1])
|
||||||
restoreOldStyleType(n.sons[1])
|
|
||||||
var typ = skipTypes(n.sons[1].typ, abstractVarRange)
|
var typ = skipTypes(n.sons[1].typ, abstractVarRange)
|
||||||
case typ.Kind
|
case typ.Kind
|
||||||
of tySequence, tyString, tyOpenArray, tyVarargs:
|
of tySequence, tyString, tyOpenArray, tyVarargs:
|
||||||
n.typ = getSysType(tyInt)
|
n.typ = getSysType(tyInt)
|
||||||
of tyArrayConstr, tyArray:
|
of tyArrayConstr, tyArray:
|
||||||
n.typ = n.sons[1].typ.sons[0] # indextype
|
n.typ = typ.sons[0] # indextype
|
||||||
of tyInt..tyInt64, tyChar, tyBool, tyEnum, tyUInt8, tyUInt16, tyUInt32:
|
of tyInt..tyInt64, tyChar, tyBool, tyEnum, tyUInt8, tyUInt16, tyUInt32:
|
||||||
n.typ = n.sons[1].typ
|
# do not skip the range!
|
||||||
|
n.typ = n.sons[1].typ.skipTypes(abstractVar)
|
||||||
else: LocalError(n.info, errInvalidArgForX, opToStr[m])
|
else: LocalError(n.info, errInvalidArgForX, opToStr[m])
|
||||||
result = n
|
result = n
|
||||||
|
|
||||||
proc semSizeof(c: PContext, n: PNode): PNode =
|
proc semSizeof(c: PContext, n: PNode): PNode =
|
||||||
if sonsLen(n) != 2:
|
if sonsLen(n) != 2:
|
||||||
LocalError(n.info, errXExpectsTypeOrValue, "sizeof")
|
LocalError(n.info, errXExpectsTypeOrValue, "sizeof")
|
||||||
else:
|
else:
|
||||||
n.sons[1] = semExprWithType(c, n.sons[1])
|
n.sons[1] = semExprWithType(c, n.sons[1])
|
||||||
restoreOldStyleType(n.sons[1])
|
#restoreOldStyleType(n.sons[1])
|
||||||
n.typ = getSysType(tyInt)
|
n.typ = getSysType(tyInt)
|
||||||
result = n
|
result = n
|
||||||
|
|
||||||
|
|
@ -261,10 +261,10 @@ proc semOf(c: PContext, n: PNode): PNode =
|
||||||
n.sons[2] = semExprWithType(c, n.sons[2])
|
n.sons[2] = semExprWithType(c, n.sons[2])
|
||||||
#restoreOldStyleType(n.sons[1])
|
#restoreOldStyleType(n.sons[1])
|
||||||
#restoreOldStyleType(n.sons[2])
|
#restoreOldStyleType(n.sons[2])
|
||||||
let a = skipTypes(n.sons[1].typ, typedescPtrs)
|
let a = skipTypes(n.sons[1].typ, abstractPtrs)
|
||||||
let b = skipTypes(n.sons[2].typ, typedescPtrs)
|
let b = skipTypes(n.sons[2].typ, abstractPtrs)
|
||||||
let x = skipTypes(n.sons[1].typ, abstractPtrs)
|
let x = skipTypes(n.sons[1].typ, abstractPtrs-{tyTypeDesc})
|
||||||
let y = skipTypes(n.sons[2].typ, abstractPtrs)
|
let y = skipTypes(n.sons[2].typ, abstractPtrs-{tyTypeDesc})
|
||||||
|
|
||||||
if x.kind == tyTypeDesc or y.kind != tyTypeDesc:
|
if x.kind == tyTypeDesc or y.kind != tyTypeDesc:
|
||||||
LocalError(n.info, errXExpectsObjectTypes, "of")
|
LocalError(n.info, errXExpectsObjectTypes, "of")
|
||||||
|
|
@ -481,7 +481,8 @@ proc analyseIfAddressTaken(c: PContext, n: PNode): PNode =
|
||||||
case n.kind
|
case n.kind
|
||||||
of nkSym:
|
of nkSym:
|
||||||
# n.sym.typ can be nil in 'check' mode ...
|
# n.sym.typ can be nil in 'check' mode ...
|
||||||
if n.sym.typ != nil and skipTypes(n.sym.typ, abstractInst).kind != tyVar:
|
if n.sym.typ != nil and
|
||||||
|
skipTypes(n.sym.typ, abstractInst-{tyTypeDesc}).kind != tyVar:
|
||||||
incl(n.sym.flags, sfAddrTaken)
|
incl(n.sym.flags, sfAddrTaken)
|
||||||
result = newHiddenAddrTaken(c, n)
|
result = newHiddenAddrTaken(c, n)
|
||||||
of nkDotExpr:
|
of nkDotExpr:
|
||||||
|
|
@ -489,12 +490,12 @@ proc analyseIfAddressTaken(c: PContext, n: PNode): PNode =
|
||||||
if n.sons[1].kind != nkSym:
|
if n.sons[1].kind != nkSym:
|
||||||
internalError(n.info, "analyseIfAddressTaken")
|
internalError(n.info, "analyseIfAddressTaken")
|
||||||
return
|
return
|
||||||
if skipTypes(n.sons[1].sym.typ, abstractInst).kind != tyVar:
|
if skipTypes(n.sons[1].sym.typ, abstractInst-{tyTypeDesc}).kind != tyVar:
|
||||||
incl(n.sons[1].sym.flags, sfAddrTaken)
|
incl(n.sons[1].sym.flags, sfAddrTaken)
|
||||||
result = newHiddenAddrTaken(c, n)
|
result = newHiddenAddrTaken(c, n)
|
||||||
of nkBracketExpr:
|
of nkBracketExpr:
|
||||||
checkMinSonsLen(n, 1)
|
checkMinSonsLen(n, 1)
|
||||||
if skipTypes(n.sons[0].typ, abstractInst).kind != tyVar:
|
if skipTypes(n.sons[0].typ, abstractInst-{tyTypeDesc}).kind != tyVar:
|
||||||
if n.sons[0].kind == nkSym: incl(n.sons[0].sym.flags, sfAddrTaken)
|
if n.sons[0].kind == nkSym: incl(n.sons[0].sym.flags, sfAddrTaken)
|
||||||
result = newHiddenAddrTaken(c, n)
|
result = newHiddenAddrTaken(c, n)
|
||||||
else:
|
else:
|
||||||
|
|
@ -515,13 +516,13 @@ proc analyseIfAddressTakenInCall(c: PContext, n: PNode) =
|
||||||
# BUGFIX: check for L-Value still needs to be done for the arguments!
|
# BUGFIX: check for L-Value still needs to be done for the arguments!
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
if i < sonsLen(t) and t.sons[i] != nil and
|
if i < sonsLen(t) and t.sons[i] != nil and
|
||||||
skipTypes(t.sons[i], abstractInst).kind == tyVar:
|
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
||||||
if isAssignable(c, n.sons[i]) notin {arLValue, arLocalLValue}:
|
if isAssignable(c, n.sons[i]) notin {arLValue, arLocalLValue}:
|
||||||
LocalError(n.sons[i].info, errVarForOutParamNeeded)
|
LocalError(n.sons[i].info, errVarForOutParamNeeded)
|
||||||
return
|
return
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
if i < sonsLen(t) and
|
if i < sonsLen(t) and
|
||||||
skipTypes(t.sons[i], abstractInst).kind == tyVar:
|
skipTypes(t.sons[i], abstractInst-{tyTypeDesc}).kind == tyVar:
|
||||||
n.sons[i] = analyseIfAddressTaken(c, n.sons[i])
|
n.sons[i] = analyseIfAddressTaken(c, n.sons[i])
|
||||||
|
|
||||||
include semmagic
|
include semmagic
|
||||||
|
|
@ -711,7 +712,8 @@ proc semDirectOp(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||||
result = evalAtCompileTime(c, result)
|
result = evalAtCompileTime(c, result)
|
||||||
|
|
||||||
proc buildStringify(c: PContext, arg: PNode): PNode =
|
proc buildStringify(c: PContext, arg: PNode): PNode =
|
||||||
if arg.typ != nil and skipTypes(arg.typ, abstractInst).kind == tyString:
|
if arg.typ != nil and
|
||||||
|
skipTypes(arg.typ, abstractInst-{tyTypeDesc}).kind == tyString:
|
||||||
result = arg
|
result = arg
|
||||||
else:
|
else:
|
||||||
result = newNodeI(nkCall, arg.info)
|
result = newNodeI(nkCall, arg.info)
|
||||||
|
|
|
||||||
|
|
@ -587,16 +587,18 @@ proc getConstExpr(m: PSym, n: PNode): PNode =
|
||||||
LocalError(a.info, errCannotEvalXBecauseIncompletelyDefined,
|
LocalError(a.info, errCannotEvalXBecauseIncompletelyDefined,
|
||||||
"sizeof")
|
"sizeof")
|
||||||
result = nil
|
result = nil
|
||||||
elif skipTypes(a.typ, abstractInst).kind in {tyArray,tyObject,tyTuple}:
|
elif skipTypes(a.typ, typedescInst).kind in
|
||||||
|
IntegralTypes+NilableTypes+{tySet}:
|
||||||
|
#{tyArray,tyObject,tyTuple}:
|
||||||
|
result = newIntNodeT(getSize(a.typ), n)
|
||||||
|
else:
|
||||||
result = nil
|
result = nil
|
||||||
# XXX: size computation for complex types is still wrong
|
# XXX: size computation for complex types is still wrong
|
||||||
else:
|
|
||||||
result = newIntNodeT(getSize(a.typ), n)
|
|
||||||
of mLow:
|
of mLow:
|
||||||
result = newIntNodeT(firstOrd(n.sons[1].typ), n)
|
result = newIntNodeT(firstOrd(n.sons[1].typ), n)
|
||||||
of mHigh:
|
of mHigh:
|
||||||
if skipTypes(n.sons[1].typ, abstractVar).kind notin
|
if skipTypes(n.sons[1].typ, abstractVar).kind notin
|
||||||
{tyOpenArray, tyVarargs, tySequence, tyString}:
|
{tyOpenArray, tyVarargs, tySequence, tyString}:
|
||||||
result = newIntNodeT(lastOrd(skipTypes(n[1].typ, abstractVar)), n)
|
result = newIntNodeT(lastOrd(skipTypes(n[1].typ, abstractVar)), n)
|
||||||
else:
|
else:
|
||||||
var a = getArrayConstr(m, n.sons[1])
|
var a = getArrayConstr(m, n.sons[1])
|
||||||
|
|
|
||||||
|
|
@ -119,11 +119,11 @@ proc semWhile(c: PContext, n: PNode): PNode =
|
||||||
closeScope(c.tab)
|
closeScope(c.tab)
|
||||||
|
|
||||||
proc toCover(t: PType): biggestInt =
|
proc toCover(t: PType): biggestInt =
|
||||||
var t2 = skipTypes(t, abstractVarRange)
|
var t2 = skipTypes(t, abstractVarRange-{tyTypeDesc})
|
||||||
if t2.kind == tyEnum and enumHasHoles(t2):
|
if t2.kind == tyEnum and enumHasHoles(t2):
|
||||||
result = sonsLen(t2.n)
|
result = sonsLen(t2.n)
|
||||||
else:
|
else:
|
||||||
result = lengthOrd(skipTypes(t, abstractVar))
|
result = lengthOrd(skipTypes(t, abstractVar-{tyTypeDesc}))
|
||||||
|
|
||||||
proc semCase(c: PContext, n: PNode): PNode =
|
proc semCase(c: PContext, n: PNode): PNode =
|
||||||
# check selector:
|
# check selector:
|
||||||
|
|
@ -133,7 +133,7 @@ proc semCase(c: PContext, n: PNode): PNode =
|
||||||
n.sons[0] = semExprWithType(c, n.sons[0])
|
n.sons[0] = semExprWithType(c, n.sons[0])
|
||||||
var chckCovered = false
|
var chckCovered = false
|
||||||
var covered: biggestint = 0
|
var covered: biggestint = 0
|
||||||
case skipTypes(n.sons[0].Typ, abstractVarRange).Kind
|
case skipTypes(n.sons[0].Typ, abstractVarRange-{tyTypeDesc}).Kind
|
||||||
of tyInt..tyInt64, tyChar, tyEnum:
|
of tyInt..tyInt64, tyChar, tyEnum:
|
||||||
chckCovered = true
|
chckCovered = true
|
||||||
of tyFloat..tyFloat128, tyString, tyError:
|
of tyFloat..tyFloat128, tyString, tyError:
|
||||||
|
|
@ -411,12 +411,12 @@ proc semForFields(c: PContext, n: PNode, m: TMagic): PNode =
|
||||||
LocalError(n.info, errWrongNumberOfVariables)
|
LocalError(n.info, errWrongNumberOfVariables)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
var tupleTypeA = skipTypes(call.sons[1].typ, abstractVar)
|
var tupleTypeA = skipTypes(call.sons[1].typ, abstractVar-{tyTypeDesc})
|
||||||
if tupleTypeA.kind notin {tyTuple, tyObject}:
|
if tupleTypeA.kind notin {tyTuple, tyObject}:
|
||||||
localError(n.info, errGenerated, "no object or tuple type")
|
localError(n.info, errGenerated, "no object or tuple type")
|
||||||
return result
|
return result
|
||||||
for i in 1..call.len-1:
|
for i in 1..call.len-1:
|
||||||
var tupleTypeB = skipTypes(call.sons[i].typ, abstractVar)
|
var tupleTypeB = skipTypes(call.sons[i].typ, abstractVar-{tyTypeDesc})
|
||||||
if not SameType(tupleTypeA, tupleTypeB):
|
if not SameType(tupleTypeA, tupleTypeB):
|
||||||
typeMismatch(call.sons[i], tupleTypeA, tupleTypeB)
|
typeMismatch(call.sons[i], tupleTypeA, tupleTypeB)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ proc semEnum(c: PContext, n: PNode, prev: PType): PType =
|
||||||
e = newSymS(skEnumField, n.sons[i].sons[0], c)
|
e = newSymS(skEnumField, n.sons[i].sons[0], c)
|
||||||
var v = semConstExpr(c, n.sons[i].sons[1])
|
var v = semConstExpr(c, n.sons[i].sons[1])
|
||||||
var strVal: PNode = nil
|
var strVal: PNode = nil
|
||||||
case skipTypes(v.typ, abstractInst).kind
|
case skipTypes(v.typ, abstractInst-{tyTypeDesc}).kind
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
if sonsLen(v) == 2:
|
if sonsLen(v) == 2:
|
||||||
strVal = v.sons[1] # second tuple part is the string value
|
strVal = v.sons[1] # second tuple part is the string value
|
||||||
|
|
@ -388,7 +388,7 @@ proc semRecordCase(c: PContext, n: PNode, check: var TIntSet, pos: var int,
|
||||||
return
|
return
|
||||||
incl(a.sons[0].sym.flags, sfDiscriminant)
|
incl(a.sons[0].sym.flags, sfDiscriminant)
|
||||||
var covered: biggestInt = 0
|
var covered: biggestInt = 0
|
||||||
var typ = skipTypes(a.sons[0].Typ, abstractVar)
|
var typ = skipTypes(a.sons[0].Typ, abstractVar-{tyTypeDesc})
|
||||||
if not isOrdinalType(typ):
|
if not isOrdinalType(typ):
|
||||||
LocalError(n.info, errSelectorMustBeOrdinal)
|
LocalError(n.info, errSelectorMustBeOrdinal)
|
||||||
elif firstOrd(typ) < 0:
|
elif firstOrd(typ) < 0:
|
||||||
|
|
|
||||||
|
|
@ -171,12 +171,19 @@ proc NotFoundError*(c: PContext, n: PNode) =
|
||||||
# fail fast:
|
# fail fast:
|
||||||
GlobalError(n.info, errTypeMismatch, "")
|
GlobalError(n.info, errTypeMismatch, "")
|
||||||
var result = msgKindToString(errTypeMismatch)
|
var result = msgKindToString(errTypeMismatch)
|
||||||
for i in countup(1, sonsLen(n) - 1):
|
for i in countup(1, sonsLen(n) - 1):
|
||||||
#debug(n.sons[i].typ)
|
var nt = n.sons[i].typ
|
||||||
if n.sons[i].kind == nkExprEqExpr:
|
if n.sons[i].kind == nkExprEqExpr:
|
||||||
add(result, renderTree(n.sons[i].sons[0]))
|
add(result, renderTree(n.sons[i].sons[0]))
|
||||||
add(result, ": ")
|
add(result, ": ")
|
||||||
let nt = n.sons[i].typ
|
if nt.isNil:
|
||||||
|
n.sons[i].sons[1] = c.semExprWithType(c, n.sons[i].sons[1])
|
||||||
|
nt = n.sons[i].sons[1].typ
|
||||||
|
n.sons[i].typ = nt
|
||||||
|
else:
|
||||||
|
if nt.isNil:
|
||||||
|
n.sons[i] = c.semExprWithType(c, n.sons[i])
|
||||||
|
nt = n.sons[i].typ
|
||||||
if nt.kind == tyError: return
|
if nt.kind == tyError: return
|
||||||
add(result, typeToString(nt))
|
add(result, typeToString(nt))
|
||||||
if i != sonsLen(n) - 1: add(result, ", ")
|
if i != sonsLen(n) - 1: add(result, ", ")
|
||||||
|
|
@ -188,7 +195,6 @@ proc NotFoundError*(c: PContext, n: PNode) =
|
||||||
if sym.kind in RoutineKinds:
|
if sym.kind in RoutineKinds:
|
||||||
add(candidates, getProcHeader(sym))
|
add(candidates, getProcHeader(sym))
|
||||||
add(candidates, "\n")
|
add(candidates, "\n")
|
||||||
#debug(sym.typ)
|
|
||||||
sym = nextOverloadIter(o, c, n.sons[0])
|
sym = nextOverloadIter(o, c, n.sons[0])
|
||||||
if candidates != "":
|
if candidates != "":
|
||||||
add(result, "\n" & msgKindToString(errButExpected) & "\n" & candidates)
|
add(result, "\n" & msgKindToString(errButExpected) & "\n" & candidates)
|
||||||
|
|
@ -712,7 +718,7 @@ proc ParamTypesMatchAux(c: PContext, m: var TCandidate, f, a: PType,
|
||||||
result = copyTree(arg)
|
result = copyTree(arg)
|
||||||
result.typ = getInstantiatedType(c, arg, m, f)
|
result.typ = getInstantiatedType(c, arg, m, f)
|
||||||
# BUG: f may not be the right key!
|
# BUG: f may not be the right key!
|
||||||
if skipTypes(result.typ, abstractVar).kind in {tyTuple}:
|
if skipTypes(result.typ, abstractVar-{tyTypeDesc}).kind in {tyTuple}:
|
||||||
result = implicitConv(nkHiddenStdConv, f, copyTree(arg), m, c)
|
result = implicitConv(nkHiddenStdConv, f, copyTree(arg), m, c)
|
||||||
# BUGFIX: use ``result.typ`` and not `f` here
|
# BUGFIX: use ``result.typ`` and not `f` here
|
||||||
of isFromIntLit:
|
of isFromIntLit:
|
||||||
|
|
@ -723,7 +729,7 @@ proc ParamTypesMatchAux(c: PContext, m: var TCandidate, f, a: PType,
|
||||||
of isEqual:
|
of isEqual:
|
||||||
inc(m.exactMatches)
|
inc(m.exactMatches)
|
||||||
result = copyTree(arg)
|
result = copyTree(arg)
|
||||||
if skipTypes(f, abstractVar).kind in {tyTuple}:
|
if skipTypes(f, abstractVar-{tyTypeDesc}).kind in {tyTuple}:
|
||||||
result = implicitConv(nkHiddenStdConv, f, copyTree(arg), m, c)
|
result = implicitConv(nkHiddenStdConv, f, copyTree(arg), m, c)
|
||||||
of isNone:
|
of isNone:
|
||||||
# do not do this in ``typeRel`` as it then can't infere T in ``ref T``:
|
# do not do this in ``typeRel`` as it then can't infere T in ``ref T``:
|
||||||
|
|
@ -885,7 +891,7 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
|
||||||
# is ok... but don't increment any counters...
|
# is ok... but don't increment any counters...
|
||||||
# we have no formal here to snoop at:
|
# we have no formal here to snoop at:
|
||||||
n.sons[a] = prepareOperand(c, n.sons[a])
|
n.sons[a] = prepareOperand(c, n.sons[a])
|
||||||
if skipTypes(n.sons[a].typ, abstractVar).kind == tyString:
|
if skipTypes(n.sons[a].typ, abstractVar-{tyTypeDesc}).kind==tyString:
|
||||||
addSon(m.call, implicitConv(nkHiddenStdConv, getSysType(tyCString),
|
addSon(m.call, implicitConv(nkHiddenStdConv, getSysType(tyCString),
|
||||||
copyTree(n.sons[a]), m, c))
|
copyTree(n.sons[a]), m, c))
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -49,16 +49,18 @@ proc isOrdinalType*(t: PType): bool
|
||||||
proc enumHasHoles*(t: PType): bool
|
proc enumHasHoles*(t: PType): bool
|
||||||
const
|
const
|
||||||
abstractPtrs* = {tyVar, tyPtr, tyRef, tyGenericInst, tyDistinct, tyOrdinal,
|
abstractPtrs* = {tyVar, tyPtr, tyRef, tyGenericInst, tyDistinct, tyOrdinal,
|
||||||
tyConst, tyMutable}
|
tyConst, tyMutable, tyTypeDesc}
|
||||||
abstractVar* = {tyVar, tyGenericInst, tyDistinct, tyOrdinal,
|
abstractVar* = {tyVar, tyGenericInst, tyDistinct, tyOrdinal,
|
||||||
tyConst, tyMutable}
|
tyConst, tyMutable, tyTypeDesc}
|
||||||
abstractRange* = {tyGenericInst, tyRange, tyDistinct, tyOrdinal,
|
abstractRange* = {tyGenericInst, tyRange, tyDistinct, tyOrdinal,
|
||||||
tyConst, tyMutable}
|
tyConst, tyMutable, tyTypeDesc}
|
||||||
abstractVarRange* = {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal,
|
abstractVarRange* = {tyGenericInst, tyRange, tyVar, tyDistinct, tyOrdinal,
|
||||||
tyConst, tyMutable}
|
tyConst, tyMutable, tyTypeDesc}
|
||||||
abstractInst* = {tyGenericInst, tyDistinct, tyConst, tyMutable, tyOrdinal}
|
abstractInst* = {tyGenericInst, tyDistinct, tyConst, tyMutable, tyOrdinal,
|
||||||
|
tyTypeDesc}
|
||||||
|
|
||||||
skipPtrs* = {tyVar, tyPtr, tyRef, tyGenericInst, tyConst, tyMutable}
|
skipPtrs* = {tyVar, tyPtr, tyRef, tyGenericInst, tyConst, tyMutable,
|
||||||
|
tyTypeDesc}
|
||||||
typedescPtrs* = abstractPtrs + {tyTypeDesc}
|
typedescPtrs* = abstractPtrs + {tyTypeDesc}
|
||||||
typedescInst* = abstractInst + {tyTypeDesc}
|
typedescInst* = abstractInst + {tyTypeDesc}
|
||||||
|
|
||||||
|
|
@ -327,7 +329,7 @@ proc canFormAcycleAux(marker: var TIntSet, typ: PType, startId: int): bool =
|
||||||
result = false
|
result = false
|
||||||
if typ == nil: return
|
if typ == nil: return
|
||||||
if tfAcyclic in typ.flags: return
|
if tfAcyclic in typ.flags: return
|
||||||
var t = skipTypes(typ, abstractInst)
|
var t = skipTypes(typ, abstractInst-{tyTypeDesc})
|
||||||
if tfAcyclic in t.flags: return
|
if tfAcyclic in t.flags: return
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyTuple, tyObject, tyRef, tySequence, tyArray, tyArrayConstr, tyOpenArray,
|
of tyTuple, tyObject, tyRef, tySequence, tyArray, tyArrayConstr, tyOpenArray,
|
||||||
|
|
@ -542,7 +544,7 @@ proc firstOrd(t: PType): biggestInt =
|
||||||
else:
|
else:
|
||||||
assert(t.n.sons[0].kind == nkSym)
|
assert(t.n.sons[0].kind == nkSym)
|
||||||
result = t.n.sons[0].sym.position
|
result = t.n.sons[0].sym.position
|
||||||
of tyGenericInst, tyDistinct, tyConst, tyMutable:
|
of tyGenericInst, tyDistinct, tyConst, tyMutable, tyTypeDesc:
|
||||||
result = firstOrd(lastSon(t))
|
result = firstOrd(lastSon(t))
|
||||||
else:
|
else:
|
||||||
InternalError("invalid kind for first(" & $t.kind & ')')
|
InternalError("invalid kind for first(" & $t.kind & ')')
|
||||||
|
|
@ -575,7 +577,7 @@ proc lastOrd(t: PType): biggestInt =
|
||||||
of tyEnum:
|
of tyEnum:
|
||||||
assert(t.n.sons[sonsLen(t.n) - 1].kind == nkSym)
|
assert(t.n.sons[sonsLen(t.n) - 1].kind == nkSym)
|
||||||
result = t.n.sons[sonsLen(t.n) - 1].sym.position
|
result = t.n.sons[sonsLen(t.n) - 1].sym.position
|
||||||
of tyGenericInst, tyDistinct, tyConst, tyMutable:
|
of tyGenericInst, tyDistinct, tyConst, tyMutable, tyTypeDesc:
|
||||||
result = lastOrd(lastSon(t))
|
result = lastOrd(lastSon(t))
|
||||||
of tyProxy: result = 0
|
of tyProxy: result = 0
|
||||||
else:
|
else:
|
||||||
|
|
@ -841,7 +843,8 @@ proc SameTypeAux(x, y: PType, c: var TSameTypeClosure): bool =
|
||||||
of tyGenericInst:
|
of tyGenericInst:
|
||||||
result = sameTypeAux(lastSon(a), lastSon(b), c)
|
result = sameTypeAux(lastSon(a), lastSon(b), c)
|
||||||
of tyTypeDesc:
|
of tyTypeDesc:
|
||||||
if TypeDescExactMatch in c.flags:
|
if c.cmp == dcEqIgnoreDistinct: result = false
|
||||||
|
elif TypeDescExactMatch in c.flags:
|
||||||
CycleCheck()
|
CycleCheck()
|
||||||
result = sameChildrenAux(x, y, c) and sameFlags(a, b)
|
result = sameChildrenAux(x, y, c) and sameFlags(a, b)
|
||||||
else:
|
else:
|
||||||
|
|
@ -971,11 +974,11 @@ proc typeAllowedAux(marker: var TIntSet, typ: PType, kind: TSymKind): bool =
|
||||||
result = true
|
result = true
|
||||||
if typ == nil: return
|
if typ == nil: return
|
||||||
if ContainsOrIncl(marker, typ.id): return
|
if ContainsOrIncl(marker, typ.id): return
|
||||||
var t = skipTypes(typ, abstractInst)
|
var t = skipTypes(typ, abstractInst-{tyTypeDesc})
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyVar:
|
of tyVar:
|
||||||
if kind == skConst: return false
|
if kind == skConst: return false
|
||||||
var t2 = skipTypes(t.sons[0], abstractInst)
|
var t2 = skipTypes(t.sons[0], abstractInst-{tyTypeDesc})
|
||||||
case t2.kind
|
case t2.kind
|
||||||
of tyVar:
|
of tyVar:
|
||||||
result = false # ``var var`` is always an invalid type:
|
result = false # ``var var`` is always an invalid type:
|
||||||
|
|
@ -989,8 +992,9 @@ proc typeAllowedAux(marker: var TIntSet, typ: PType, kind: TSymKind): bool =
|
||||||
if not result: break
|
if not result: break
|
||||||
if result and t.sons[0] != nil:
|
if result and t.sons[0] != nil:
|
||||||
result = typeAllowedAux(marker, t.sons[0], skResult)
|
result = typeAllowedAux(marker, t.sons[0], skResult)
|
||||||
of tyExpr, tyStmt, tyTypeDesc:
|
of tyExpr, tyStmt, tyTypeDesc:
|
||||||
result = true
|
result = true
|
||||||
|
# XXX er ... no? these should not be allowed!
|
||||||
of tyGenericBody, tyGenericParam, tyForward, tyNone, tyGenericInvokation,
|
of tyGenericBody, tyGenericParam, tyForward, tyNone, tyGenericInvokation,
|
||||||
tyTypeClass:
|
tyTypeClass:
|
||||||
result = false
|
result = false
|
||||||
|
|
@ -1003,7 +1007,7 @@ proc typeAllowedAux(marker: var TIntSet, typ: PType, kind: TSymKind): bool =
|
||||||
of tyGenericInst, tyDistinct:
|
of tyGenericInst, tyDistinct:
|
||||||
result = typeAllowedAux(marker, lastSon(t), kind)
|
result = typeAllowedAux(marker, lastSon(t), kind)
|
||||||
of tyRange:
|
of tyRange:
|
||||||
result = skipTypes(t.sons[0], abstractInst).kind in
|
result = skipTypes(t.sons[0], abstractInst-{tyTypeDesc}).kind in
|
||||||
{tyChar, tyEnum, tyInt..tyFloat128}
|
{tyChar, tyEnum, tyInt..tyFloat128}
|
||||||
of tyOpenArray, tyVarargs:
|
of tyOpenArray, tyVarargs:
|
||||||
result = (kind == skParam) and typeAllowedAux(marker, t.sons[0], skVar)
|
result = (kind == skParam) and typeAllowedAux(marker, t.sons[0], skVar)
|
||||||
|
|
@ -1171,6 +1175,8 @@ proc computeSizeAux(typ: PType, a: var biggestInt): biggestInt =
|
||||||
result = align(result, a)
|
result = align(result, a)
|
||||||
of tyGenericInst, tyDistinct, tyGenericBody, tyMutable, tyConst, tyIter:
|
of tyGenericInst, tyDistinct, tyGenericBody, tyMutable, tyConst, tyIter:
|
||||||
result = computeSizeAux(lastSon(typ), a)
|
result = computeSizeAux(lastSon(typ), a)
|
||||||
|
of tyTypeDesc:
|
||||||
|
result = (if typ.len == 1: computeSizeAux(typ.sons[0], a) else: -1)
|
||||||
of tyProxy: result = 1
|
of tyProxy: result = 1
|
||||||
else:
|
else:
|
||||||
#internalError("computeSizeAux()")
|
#internalError("computeSizeAux()")
|
||||||
|
|
|
||||||
6
todo.txt
6
todo.txt
|
|
@ -13,6 +13,9 @@ version 0.9.2
|
||||||
- fix:
|
- fix:
|
||||||
- 'result' is not properly cleaned for NRVO
|
- 'result' is not properly cleaned for NRVO
|
||||||
- document NimMain and check whether it works for threading
|
- document NimMain and check whether it works for threading
|
||||||
|
- fix destructors; don't work yet when used as expression; alternative for
|
||||||
|
version 1: disallow expressions yielding a type with a destructor that are
|
||||||
|
not in a 'let/var' context (p(a.openFile, b.openFile) makes no sense anyway)
|
||||||
|
|
||||||
|
|
||||||
version 0.9.4
|
version 0.9.4
|
||||||
|
|
@ -65,9 +68,6 @@ version 0.9.XX
|
||||||
- object branch transitions can't work with the current 'reset'; add a 'reset'
|
- object branch transitions can't work with the current 'reset'; add a 'reset'
|
||||||
with an additional parameter --> re-evaluate this issue after constructors
|
with an additional parameter --> re-evaluate this issue after constructors
|
||||||
have been added
|
have been added
|
||||||
- fix destructors; don't work yet when used as expression; alternative for
|
|
||||||
version 1: disallow expressions yielding a type with a destructor that are
|
|
||||||
not in a 'let/var' context (p(a.openFile, b.openFile) makes no sense anyway)
|
|
||||||
- document nimdoc properly finally
|
- document nimdoc properly finally
|
||||||
- make 'clamp' a magic for the range stuff
|
- make 'clamp' a magic for the range stuff
|
||||||
- better type syntax for functions and tuples: tuple(int, int); (int,int)->int
|
- better type syntax for functions and tuples: tuple(int, int); (int,int)->int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue