Revert "more test made green"

This reverts commit 911e6e710f.
This commit is contained in:
Araq 2013-05-27 23:16:56 +02:00
commit c67abd7e61
6 changed files with 89 additions and 96 deletions

View file

@ -1285,8 +1285,7 @@ proc getStrOrChar*(a: PNode): string =
proc isGenericRoutine*(s: PSym): bool = proc isGenericRoutine*(s: PSym): bool =
case s.kind case s.kind
of skProc, skTemplate, skMacro, skIterator, skMethod, skConverter: of skProc, skTemplate, skMacro, skIterator, skMethod, skConverter:
result = sfFromGeneric in s.flags or result = sfFromGeneric in s.flags
(s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty)
else: nil else: nil
proc isRoutine*(s: PSym): bool {.inline.} = proc isRoutine*(s: PSym): bool {.inline.} =

View file

@ -220,7 +220,7 @@ proc getHiddenParam(routine: PSym): PSym =
proc isInnerProc(s, outerProc: PSym): bool {.inline.} = proc isInnerProc(s, outerProc: PSym): bool {.inline.} =
result = s.kind in {skProc, skMethod, skConverter} and result = s.kind in {skProc, skMethod, skConverter} and
s.owner == outerProc s.owner == outerProc and not isGenericRoutine(s)
#s.typ.callConv == ccClosure #s.typ.callConv == ccClosure
proc addClosureParam(i: PInnerContext, e: PEnv) = proc addClosureParam(i: PInnerContext, e: PEnv) =

View file

@ -91,8 +91,17 @@ proc instantiateBody(c: PContext, n: PNode, result: PSym) =
addDecl(c, result) addDecl(c, result)
pushProcCon(c, result) pushProcCon(c, result)
# add params to scope # add params to scope
for i in 1 .. <result.typ.n.len: let origFormalParams = result.typ.n
var param = result.typ.n.sons[i].sym result.typ.n = newNodeI(nkFormalParams,
origFormalParams.info,
origFormalParams.len)
result.typ.n.sons[0] = copyNode(origFormalParams.sons[0])
for i in 1 .. <result.typ.len:
let origParam = origFormalParams[i].sym
var param = copySym(origParam)
result.typ.n.sons[i] = newSymNode(param)
param.typ = result.typ.sons[i]
param.ast = origParam.ast
param.owner = result param.owner = result
addParamOrResult(c, param, result.kind) addParamOrResult(c, param, result.kind)
# debug result.typ.n # debug result.typ.n
@ -141,15 +150,6 @@ proc instGenericContainer(c: PContext, n: PNode, header: PType): PType =
proc fixupProcType(c: PContext, genericType: PType, proc fixupProcType(c: PContext, genericType: PType,
inst: TInstantiation): PType = inst: TInstantiation): PType =
# XXX: This is starting to look suspiciously like ReplaceTypeVarsT
# there are few apparent differences, but maybe the code could be
# moved over.
# * the code here uses the new genericSym.position property when
# doing lookups.
# * the handling of tyTypeDesc seems suspicious in ReplaceTypeVarsT
# typedesc params were previously handled in the second pass of
# semParamList
# * void (nkEmpty) params doesn't seem to be stripped in ReplaceTypeVarsT
result = genericType result = genericType
if result == nil: return if result == nil: return
@ -167,8 +167,7 @@ proc fixupProcType(c: PContext, genericType: PType,
if genericType.sons == nil: return if genericType.sons == nil: return
var head = 0 var head = 0
for i in 0 .. <genericType.sons.len: for i in 0 .. <genericType.sons.len:
let origType = genericType.sons[i] var changed = fixupProcType(c, genericType.sons[i], inst)
var changed = fixupProcType(c, origType, inst)
if changed != genericType.sons[i]: if changed != genericType.sons[i]:
var changed = changed.skipIntLit var changed = changed.skipIntLit
if result == genericType: if result == genericType:
@ -195,11 +194,7 @@ proc fixupProcType(c: PContext, genericType: PType,
if result.n != nil: if result.n != nil:
if result.n.kind == nkRecList: if result.n.kind == nkRecList:
for son in result.n.sons: result.n.sons[head].typ = changed
if son.typ == origType:
son.typ = changed
son.sym = copySym(son.sym, true)
son.sym.typ = changed
if result.n.kind == nkFormalParams: if result.n.kind == nkFormalParams:
if i != 0: if i != 0:
let origParam = result.n.sons[head].sym let origParam = result.n.sons[head].sym
@ -216,8 +211,8 @@ proc fixupProcType(c: PContext, genericType: PType,
for i in 1 .. <genericType.sons.len: for i in 1 .. <genericType.sons.len:
result.sons[i] = fixupProcType(c, result.sons[i], inst) result.sons[i] = fixupProcType(c, result.sons[i], inst)
result = instGenericContainer(c, getInfoContext(-1), result) result = instGenericContainer(c, getInfoContext(-1), result)
else:
else: nil nil
proc generateInstance(c: PContext, fn: PSym, pt: TIdTable, proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
info: TLineInfo): PSym = info: TLineInfo): PSym =

View file

@ -374,7 +374,7 @@ proc semCaseBranch(c: PContext, t, branch: PNode, branchIndex: int,
# for ``{}`` we want to trigger the type mismatch in ``fitNode``: # for ``{}`` we want to trigger the type mismatch in ``fitNode``:
if r.kind != nkCurly or len(r) == 0: if r.kind != nkCurly or len(r) == 0:
checkMinSonsLen(t, 1) checkMinSonsLen(t, 1)
branch.sons[i] = skipConv(fitNode(c, t.sons[0].typ, r)) branch.sons[i] = fitNode(c, t.sons[0].typ, r)
inc(covered) inc(covered)
else: else:
# constant sets have special rules # constant sets have special rules

View file

@ -14,7 +14,7 @@ type
type type
TMyObject = object of TObject TMyObject = object of TObject
case disp: range[0..4] case disp: range[0..4]:
of 0: arg: char of 0: arg: char
of 1: s: string of 1: s: string
else: wtf: bool else: wtf: bool

View file

@ -33,4 +33,3 @@ type
proc bar[a,b](f: TFoo[a,b], x: a) = echo(x, " ", f.lorem, f.ipsum) proc bar[a,b](f: TFoo[a,b], x: a) = echo(x, " ", f.lorem, f.ipsum)
proc bar[a,b](f: TFoo[a,b], x: b) = echo(x, " ", f.lorem, f.ipsum) proc bar[a,b](f: TFoo[a,b], x: b) = echo(x, " ", f.lorem, f.ipsum)