some attempts at fixing staticT; breaks lots of tests

This commit is contained in:
Araq 2015-05-04 00:09:45 +02:00
commit 0922f4a512
5 changed files with 34 additions and 30 deletions

View file

@ -97,7 +97,7 @@ var
gOptions*: TOptions = {optObjCheck, optFieldCheck, optRangeCheck, gOptions*: TOptions = {optObjCheck, optFieldCheck, optRangeCheck,
optBoundsCheck, optOverflowCheck, optAssert, optWarns, optBoundsCheck, optOverflowCheck, optAssert, optWarns,
optHints, optStackTrace, optLineTrace, optHints, optStackTrace, optLineTrace,
optPatterns, optNilCheck} optPatterns, optNilCheck, optImplicitStatic}
gGlobalOptions*: TGlobalOptions = {optThreadAnalysis} gGlobalOptions*: TGlobalOptions = {optThreadAnalysis}
gExitcode*: int8 gExitcode*: int8
gCmd*: TCommands = cmdNone # the command gCmd*: TCommands = cmdNone # the command

View file

@ -692,20 +692,6 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
else: return result else: return result
result.typ = semfold.getIntervalType(callee.magic, call) result.typ = semfold.getIntervalType(callee.magic, call)
block maybeLabelAsStatic:
# XXX: temporary work-around needed for tlateboundstatic.
# This is certainly not correct, but it will get the job
# done until we have a more robust infrastructure for
# implicit statics.
if n.len > 1:
for i in 1 .. <n.len:
# see bug #2113, it's possible that n[i].typ for errornous code:
if n[i].typ.isNil or n[i].typ.kind != tyStatic or
tfUnresolved notin n[i].typ.flags:
break maybeLabelAsStatic
n.typ = newTypeWithSons(c, tyStatic, @[n.typ])
n.typ.flags.incl tfUnresolved
# optimization pass: not necessary for correctness of the semantic pass # optimization pass: not necessary for correctness of the semantic pass
if {sfNoSideEffect, sfCompileTime} * callee.flags != {} and if {sfNoSideEffect, sfCompileTime} * callee.flags != {} and
{sfForward, sfImportc} * callee.flags == {} and n.typ != nil: {sfForward, sfImportc} * callee.flags == {} and n.typ != nil:

View file

@ -1235,13 +1235,6 @@ proc paramTypesMatchAux(m: var TCandidate, f, argType: PType,
if m.callee.kind == tyGenericBody and tfGenericTypeParam notin argType.flags: if m.callee.kind == tyGenericBody and tfGenericTypeParam notin argType.flags:
result = newNodeIT(nkType, argOrig.info, makeTypeFromExpr(c, arg)) result = newNodeIT(nkType, argOrig.info, makeTypeFromExpr(c, arg))
return return
else:
var evaluated = c.semTryConstExpr(c, arg)
if evaluated != nil:
arg.typ = newTypeS(tyStatic, c)
arg.typ.sons = @[evaluated.typ]
arg.typ.n = evaluated
argType = arg.typ
var var
a = if c.inTypeClass > 0: argType.skipTypes({tyTypeDesc, tyFieldAccessor}) a = if c.inTypeClass > 0: argType.skipTypes({tyTypeDesc, tyFieldAccessor})
@ -1468,6 +1461,10 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
if not n.isLValue: if not n.isLValue:
m.state = csNoMatch m.state = csNoMatch
return return
elif formal.typ.kind == tyStatic:
if not n.isStaticT_Expr:
m.state = csNoMatch
return
var var
# iterates over formal parameters # iterates over formal parameters

View file

@ -99,17 +99,14 @@ proc getMagic*(op: PNode): TMagic =
else: result = mNone else: result = mNone
else: result = mNone else: result = mNone
proc treeToSym*(t: PNode): PSym =
result = t.sym
proc isConstExpr*(n: PNode): bool = proc isConstExpr*(n: PNode): bool =
result = (n.kind in result = (n.kind in
{nkCharLit..nkInt64Lit, nkStrLit..nkTripleStrLit, {nkCharLit..nkUInt64Lit, nkStrLit..nkTripleStrLit,
nkFloatLit..nkFloat64Lit, nkNilLit}) or (nfAllConst in n.flags) nkFloatLit..nkFloat64Lit, nkNilLit}) or (nfAllConst in n.flags)
proc isDeepConstExpr*(n: PNode): bool = proc isDeepConstExpr*(n: PNode): bool =
case n.kind case n.kind
of nkCharLit..nkInt64Lit, nkStrLit..nkTripleStrLit, of nkCharLit..nkUInt64Lit, nkStrLit..nkTripleStrLit,
nkFloatLit..nkFloat64Lit, nkNilLit: nkFloatLit..nkFloat64Lit, nkNilLit:
result = true result = true
of nkExprEqExpr, nkExprColonExpr, nkHiddenStdConv, nkHiddenSubConv: of nkExprEqExpr, nkExprColonExpr, nkHiddenStdConv, nkHiddenSubConv:
@ -122,6 +119,21 @@ proc isDeepConstExpr*(n: PNode): bool =
result = n.typ.isNil or n.typ.skipTypes({tyGenericInst, tyDistinct}).kind != tyObject result = n.typ.isNil or n.typ.skipTypes({tyGenericInst, tyDistinct}).kind != tyObject
else: discard else: discard
proc isStaticT_Expr*(n: PNode): bool =
case n.kind
of nkCharLit..nkUInt64Lit, nkStrLit..nkTripleStrLit,
nkFloatLit..nkFloat64Lit, nkNilLit:
result = true
of nkExprEqExpr, nkExprColonExpr, nkHiddenStdConv, nkHiddenSubConv:
result = isStaticT_Expr(n.sons[1])
of nkCurly, nkBracket, nkPar, nkObjConstr, nkClosure:
for i in 0 .. <n.len:
if not isStaticT_Expr(n.sons[i]): return false
result = true
of nkSym:
result = n.sym.kind in {skConst, skEnumField}
else: discard
proc flattenTreeAux(d, a: PNode, op: TMagic) = proc flattenTreeAux(d, a: PNode, op: TMagic) =
if (getMagic(a) == op): # a is a "leaf", so add it: if (getMagic(a) == op): # a is a "leaf", so add it:
for i in countup(1, sonsLen(a) - 1): # BUGFIX for i in countup(1, sonsLen(a) - 1): # BUGFIX

View file

@ -3,9 +3,6 @@ News
==== ====
.. ..
2015-05-05 Version 0.11.2 released
==================================
Changes affecting backwards compatibility Changes affecting backwards compatibility
----------------------------------------- -----------------------------------------
@ -18,6 +15,18 @@ News
-------- --------
..
2015-05-03 Version 0.11.2 released
==================================
This is just a bugfix release that fixes the most pressing regressions we
introduced with version 0.11.0. The way type computations are performed was
changed significantly causing all sort of problems. Sorry for the
inconvenience; we grew overconfident our large test suite would prevent these
things.
2015-04-30 Version 0.11.0 released 2015-04-30 Version 0.11.0 released
================================== ==================================