From 0662ec4a434f4656b5afc486bc4ebaab82c52da6 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 27 May 2013 23:18:38 +0200 Subject: [PATCH] Revert "static and default params for generics" This reverts commit 46813bbe4e1423181521d4792b9af7593f48fa1f. --- compiler/ast.nim | 2 - compiler/semstmts.nim | 3 +- compiler/semtypes.nim | 131 ++++++++++++++++++------------------------ compiler/sigmatch.nim | 19 ++---- 4 files changed, 62 insertions(+), 93 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index 174c3f94ba..e35bf25ef3 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -674,8 +674,6 @@ type # for record types a nkRecord node # for enum types a list of symbols # for tyInt it can be the int literal - # for procs and tyGenericBody, it's the - # formal param list # else: unused destructor*: PSym # destructor. warning: nil here may not necessary # mean that there is no destructor. diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 9ae8aaca68..b63c20548f 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -710,8 +710,7 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) = # TGObj[T] = object # TAlias[T] = TGObj[T] # - s.typ.n = semGenericParamList(c, a.sons[1], s.typ) - a.sons[1] = s.typ.n + a.sons[1] = semGenericParamList(c, a.sons[1], s.typ) s.typ.size = -1 # could not be computed properly # we fill it out later. For magic generics like 'seq', it won't be filled # so we use tyEmpty instead of nil to not crash for strange conversions diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 351794435b..c975abb26b 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -794,44 +794,29 @@ proc semGenericParamInInvokation(c: PContext, n: PNode): PType = proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType = result = newOrPrevType(tyGenericInvokation, prev, c) - addSonSkipIntLit(result, s.typ) - - template addToResult(typ) = - if typ.isNil: - InternalAssert false - rawAddSon(result, typ) - else: addSonSkipIntLit(result, typ) - + var isConcrete = true if s.typ == nil: LocalError(n.info, errCannotInstantiateX, s.name.s) return newOrPrevType(tyError, prev, c) - elif s.typ.kind == tyForward: - for i in countup(1, sonsLen(n)-1): - var elem = semGenericParamInInvokation(c, n.sons[i]) - addToResult(elem) - else: - internalAssert s.typ.kind == tyGenericBody - - var m = newCandidate(s, n) - matches(c, n, copyTree(n), m) - - if m.state != csMatch: - LocalError(n.info, errWrongNumberOfArguments) - return newOrPrevType(tyError, prev, c) - - var isConcrete = true - - for i in 1 ..