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,
optBoundsCheck, optOverflowCheck, optAssert, optWarns,
optHints, optStackTrace, optLineTrace,
optPatterns, optNilCheck}
optPatterns, optNilCheck, optImplicitStatic}
gGlobalOptions*: TGlobalOptions = {optThreadAnalysis}
gExitcode*: int8
gCmd*: TCommands = cmdNone # the command

View file

@ -692,20 +692,6 @@ proc evalAtCompileTime(c: PContext, n: PNode): PNode =
else: return result
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
if {sfNoSideEffect, sfCompileTime} * callee.flags != {} and
{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:
result = newNodeIT(nkType, argOrig.info, makeTypeFromExpr(c, arg))
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
a = if c.inTypeClass > 0: argType.skipTypes({tyTypeDesc, tyFieldAccessor})
@ -1468,6 +1461,10 @@ proc matchesAux(c: PContext, n, nOrig: PNode,
if not n.isLValue:
m.state = csNoMatch
return
elif formal.typ.kind == tyStatic:
if not n.isStaticT_Expr:
m.state = csNoMatch
return
var
# iterates over formal parameters

View file

@ -99,17 +99,14 @@ proc getMagic*(op: PNode): TMagic =
else: result = mNone
else: result = mNone
proc treeToSym*(t: PNode): PSym =
result = t.sym
proc isConstExpr*(n: PNode): bool =
result = (n.kind in
{nkCharLit..nkInt64Lit, nkStrLit..nkTripleStrLit,
{nkCharLit..nkUInt64Lit, nkStrLit..nkTripleStrLit,
nkFloatLit..nkFloat64Lit, nkNilLit}) or (nfAllConst in n.flags)
proc isDeepConstExpr*(n: PNode): bool =
case n.kind
of nkCharLit..nkInt64Lit, nkStrLit..nkTripleStrLit,
of nkCharLit..nkUInt64Lit, nkStrLit..nkTripleStrLit,
nkFloatLit..nkFloat64Lit, nkNilLit:
result = true
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
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) =
if (getMagic(a) == op): # a is a "leaf", so add it:
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
-----------------------------------------
@ -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
==================================