parent
8407a57499
commit
afbcd1b330
34 changed files with 530 additions and 314 deletions
|
|
@ -377,8 +377,8 @@ proc handleRange(f, a: PType, min, max: TTypeKind): TTypeRelation =
|
|||
if k == f.kind: result = isSubrange
|
||||
elif k == tyInt and f.kind in {tyRange, tyInt8..tyInt64,
|
||||
tyUInt..tyUInt64} and
|
||||
isIntLit(ab) and ab.n.intVal >= firstOrd(nil, f) and
|
||||
ab.n.intVal <= lastOrd(nil, f):
|
||||
isIntLit(ab) and getInt(ab.n) >= firstOrd(nil, f) and
|
||||
getInt(ab.n) <= lastOrd(nil, f):
|
||||
# passing 'nil' to firstOrd/lastOrd here as type checking rules should
|
||||
# not depent on the target integer size configurations!
|
||||
# integer literal in the proper range; we want ``i16 + 4`` to stay an
|
||||
|
|
@ -902,10 +902,10 @@ proc inferStaticsInRange(c: var TCandidate,
|
|||
allowUnresolved = true)
|
||||
let upperBound = tryResolvingStaticExpr(c, inferred.n[1],
|
||||
allowUnresolved = true)
|
||||
template doInferStatic(e: PNode, r: BiggestInt) =
|
||||
template doInferStatic(e: PNode, r: Int128) =
|
||||
var exp = e
|
||||
var rhs = r
|
||||
if inferStaticParam(c, exp, rhs):
|
||||
if inferStaticParam(c, exp, toInt64(rhs)):
|
||||
return isGeneric
|
||||
else:
|
||||
failureToInferStaticParam(c.c.config, exp)
|
||||
|
|
@ -918,7 +918,7 @@ proc inferStaticsInRange(c: var TCandidate,
|
|||
return isNone
|
||||
doInferStatic(upperBound, lengthOrd(c.c.config, concrete) + lowerBound.intVal - 1)
|
||||
elif upperBound.kind == nkIntLit:
|
||||
doInferStatic(lowerBound, upperBound.intVal + 1 - lengthOrd(c.c.config, concrete))
|
||||
doInferStatic(lowerBound, getInt(upperBound) + 1 - lengthOrd(c.c.config, concrete))
|
||||
|
||||
template subtypeCheck() =
|
||||
if result <= isSubrange and f.lastSon.skipTypes(abstractInst).kind in {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue