diff --git a/compiler/ast.nim b/compiler/ast.nim index ee6391919..63b656715 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -212,8 +212,6 @@ type nkIteratorTy, # iterator type nkSharedTy, # 'shared T' # we use 'nkPostFix' for the 'not nil' addition - nkInTy, # prefix `in` used to mark contravariant types - nkOutTy, # prefix `out` used to mark covariant types nkEnumTy, # enum body nkEnumFieldDef, # `ident = expr` in an enumeration nkArgList, # argument list @@ -226,7 +224,7 @@ type TNodeKinds* = set[TNodeKind] type - TSymFlag* = enum # already 32 flags! + TSymFlag* = enum # already 33 flags! sfUsed, # read access of sym (for warnings) or simply used sfExported, # symbol is exported from module sfFromGeneric, # symbol is instantiation of a generic; this is needed @@ -270,9 +268,6 @@ type sfDiscardable, # returned value may be discarded implicitly sfOverriden, # proc is overriden sfGenSym # symbol is 'gensym'ed; do not add to symbol table - sfCovariant # covariant generic param mimicing a ptr type - sfWeakCovariant # covariant generic param mimicing a seq/array type - sfContravariant # contravariant generic param TSymFlags* = set[TSymFlag] @@ -460,7 +455,7 @@ type nfBlockArg # this a stmtlist appearing in a call (e.g. a do block) TNodeFlags* = set[TNodeFlag] - TTypeFlag* = enum # keep below 32 for efficiency reasons (now: 30) + TTypeFlag* = enum # keep below 32 for efficiency reasons (now: beyond that) tfVarargs, # procedure has C styled varargs # tyArray type represeting a varargs list tfNoSideEffect, # procedure type does not allow side effects @@ -513,6 +508,9 @@ type tfTriggersCompileTime # uses the NimNode type which make the proc # implicitly '.compiletime' tfRefsAnonObj # used for 'ref object' and 'ptr object' + tfCovariant # covariant generic param mimicing a ptr type + tfWeakCovariant # covariant generic param mimicing a seq/array type + tfContravariant # contravariant generic param TTypeFlags* = set[TTypeFlag] diff --git a/compiler/parser.nim b/compiler/parser.nim index 788ad7cd7..d4c44788e 100644 --- a/compiler/parser.nim +++ b/compiler/parser.nim @@ -1521,9 +1521,9 @@ proc parseGenericParam(p: var TParser): PNode = while true: case p.tok.tokType of tkIn, tkOut: - let kind = if p.tok.tokType == tkIn: nkInTy - else: nkOutTy - a = newNodeP(kind, p) + let x = p.lex.cache.getIdent(if p.tok.tokType == tkIn: "in" else: "out") + a = newNodeP(nkPrefix, p) + a.addSon newIdentNodeP(x, p) getTok(p) expectIdent(p) a.addSon(parseSymbol(p)) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index f15cdddee..61590985c 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -758,7 +758,7 @@ proc checkCovariantParamsUsages(genericType: PType) = case t.kind of tyGenericParam: - t.sym.flags.incl sfWeakCovariant + t.flags.incl tfWeakCovariant return true of tyObject: @@ -783,17 +783,17 @@ proc checkCovariantParamsUsages(genericType: PType) = for i in 1 ..