diff options
-rw-r--r-- | compiler/sem.nim | 1 | ||||
-rw-r--r-- | compiler/semstmts.nim | 4 | ||||
-rw-r--r-- | compiler/semtypes.nim | 10 |
3 files changed, 9 insertions, 6 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim index c29cbe384..74fa09a57 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -354,7 +354,6 @@ proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym, #if c.evalContext == nil: # c.evalContext = c.createEvalContext(emStatic) - result = evalMacroCall(c.module, n, nOrig, sym) if efNoSemCheck notin flags: result = semAfterMacroCall(c, result, sym, flags) diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index f6bfca955..dcc7ecd92 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -781,9 +781,9 @@ proc typeSectionFinalPass(c: PContext, n: PNode) = var x = a[2] while x.kind in {nkStmtList, nkStmtListExpr} and x.len > 0: x = x.lastSon - if x.kind notin {nkObjectTy, nkDistinctTy, nkEnumTy, nkEmpty}: + if x.kind notin {nkObjectTy, nkDistinctTy, nkEnumTy, nkEmpty} and + s.typ.kind notin {tyObject, tyEnum, tyDistinct}: # type aliases are hard: - #MessageOut('for type ' + typeToString(s.typ)); var t = semTypeNode(c, x, nil) assert t != nil if t.kind in {tyObject, tyEnum, tyDistinct}: diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index ba17cc307..9d0afd8b1 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1094,10 +1094,14 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType = result = instGenericContainer(c, n.info, result, allowMetaTypes = false) -proc semTypeExpr(c: PContext, n: PNode): PType = +proc semTypeExpr(c: PContext, n: PNode; prev: PType): PType = var n = semExprWithType(c, n, {efDetermineType}) if n.typ.kind == tyTypeDesc: result = n.typ.base + # fix types constructed by macros: + if prev != nil and prev.sym != nil and result.sym.isNil: + result.sym = prev.sym + result.sym.typ = result else: localError(n.info, errTypeExpected, n.renderTree) result = errorType(c) @@ -1177,7 +1181,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType = else: localError(n.info, errGenerated, "invalid type") elif n[0].kind notin nkIdentKinds: - result = semTypeExpr(c, n) + result = semTypeExpr(c, n, prev) else: let op = considerQuotedIdent(n.sons[0]) if op.id in {ord(wAnd), ord(wOr)} or op.s == "|": @@ -1218,7 +1222,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType = let typExpr = semExprWithType(c, n.sons[1], {efInTypeof}) result = typExpr.typ else: - result = semTypeExpr(c, n) + result = semTypeExpr(c, n, prev) of nkWhenStmt: var whenResult = semWhen(c, n, false) if whenResult.kind == nkStmtList: whenResult.kind = nkStmtListType |