From a8ba628bcd2535bc55e3bf67737e93ae99906a63 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 27 May 2013 23:20:41 +0200 Subject: [PATCH] Revert "fixes #267" This reverts commit 7fccdedcb5d1e583039b2ea2ae6564412a0f5104. --- compiler/ast.nim | 15 ++-- compiler/semdata.nim | 5 -- compiler/seminst.nim | 103 +++++----------------------- compiler/semtypes.nim | 156 ++++++++++++++++++------------------------ compiler/types.nim | 2 - 5 files changed, 97 insertions(+), 184 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index e35bf25ef3..d4d5bce9cc 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -365,8 +365,12 @@ type tfFromGeneric, # type is an instantiation of a generic; this is needed # because for instantiations of objects, structural # type equality has to be used - tfUnresolved, # marks unresolved typedesc params: e.g. - # proc foo(T: typedesc, list: seq[T]): var T + tfInstantiated, # XXX: used to mark generic params after instantiation. + # if the concrete type happens to be an implicit generic + # this can lead to invalid proc signatures in the second + # pass of semProcTypeNode performed after instantiation. + # this won't be needed if we don't perform this redundant + # second pass (stay tuned). tfRetType, # marks return types in proc (used to detect type classes # used as return types for return type inference) tfAll, # type class requires all constraints to be met (default) @@ -1003,8 +1007,8 @@ proc NewType(kind: TTypeKind, owner: PSym): PType = result.size = - 1 result.align = 2 # default alignment result.id = getID() - when debugIds: - RegisterId(result) + when debugIds: + RegisterId(result) #if result.id < 2000 then # MessageOut(typeKindToStr[kind] & ' has id: ' & toString(result.id)) @@ -1041,6 +1045,7 @@ proc copyType(t: PType, owner: PSym, keepId: bool): PType = if keepId: result.id = t.id else: + result.id = getID() when debugIds: RegisterId(result) result.sym = t.sym # backend-info should not be copied @@ -1285,7 +1290,7 @@ proc isGenericRoutine*(s: PSym): bool = of skProc, skTemplate, skMacro, skIterator, skMethod, skConverter: result = s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty else: nil - + proc isRoutine*(s: PSym): bool {.inline.} = result = s.kind in {skProc, skTemplate, skMacro, skIterator, skMethod, skConverter} diff --git a/compiler/semdata.nim b/compiler/semdata.nim index 127842a5a6..4c94d08129 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -207,11 +207,6 @@ proc makeTypeDesc*(c: PContext, typ: PType): PType = proc newTypeS(kind: TTypeKind, c: PContext): PType = result = newType(kind, getCurrOwner()) -proc newTypeWithSons*(c: PContext, kind: TTypeKind, - sons: seq[PType]): PType = - result = newType(kind, getCurrOwner()) - result.sons = sons - proc errorType*(c: PContext): PType = ## creates a type representing an error state result = newTypeS(tyError, c) diff --git a/compiler/seminst.nim b/compiler/seminst.nim index 35ed009659..9dc99d173e 100644 --- a/compiler/seminst.nim +++ b/compiler/seminst.nim @@ -38,6 +38,7 @@ proc instantiateGenericParamList(c: PContext, n: PNode, pt: TIdTable, #t = instGenericContainer(c, a, t) t = generateTypeInstance(c, pt, a, t) #t = ReplaceTypeVarsT(cl, t) + t.flags.incl tfInstantiated s.typ = t addDecl(c, s) entry.concreteTypes[i] = t @@ -83,28 +84,11 @@ proc freshGenSyms(n: PNode, owner: PSym, symMap: var TIdTable) = else: for i in 0 ..