fixes #4066
This commit is contained in:
parent
3ac6bd8ae1
commit
2ac3e12372
3 changed files with 9 additions and 6 deletions
|
|
@ -354,7 +354,6 @@ proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym,
|
||||||
|
|
||||||
#if c.evalContext == nil:
|
#if c.evalContext == nil:
|
||||||
# c.evalContext = c.createEvalContext(emStatic)
|
# c.evalContext = c.createEvalContext(emStatic)
|
||||||
|
|
||||||
result = evalMacroCall(c.module, n, nOrig, sym)
|
result = evalMacroCall(c.module, n, nOrig, sym)
|
||||||
if efNoSemCheck notin flags:
|
if efNoSemCheck notin flags:
|
||||||
result = semAfterMacroCall(c, result, sym, flags)
|
result = semAfterMacroCall(c, result, sym, flags)
|
||||||
|
|
|
||||||
|
|
@ -781,9 +781,9 @@ proc typeSectionFinalPass(c: PContext, n: PNode) =
|
||||||
var x = a[2]
|
var x = a[2]
|
||||||
while x.kind in {nkStmtList, nkStmtListExpr} and x.len > 0:
|
while x.kind in {nkStmtList, nkStmtListExpr} and x.len > 0:
|
||||||
x = x.lastSon
|
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:
|
# type aliases are hard:
|
||||||
#MessageOut('for type ' + typeToString(s.typ));
|
|
||||||
var t = semTypeNode(c, x, nil)
|
var t = semTypeNode(c, x, nil)
|
||||||
assert t != nil
|
assert t != nil
|
||||||
if t.kind in {tyObject, tyEnum, tyDistinct}:
|
if t.kind in {tyObject, tyEnum, tyDistinct}:
|
||||||
|
|
|
||||||
|
|
@ -1094,10 +1094,14 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
||||||
result = instGenericContainer(c, n.info, result,
|
result = instGenericContainer(c, n.info, result,
|
||||||
allowMetaTypes = false)
|
allowMetaTypes = false)
|
||||||
|
|
||||||
proc semTypeExpr(c: PContext, n: PNode): PType =
|
proc semTypeExpr(c: PContext, n: PNode; prev: PType): PType =
|
||||||
var n = semExprWithType(c, n, {efDetermineType})
|
var n = semExprWithType(c, n, {efDetermineType})
|
||||||
if n.typ.kind == tyTypeDesc:
|
if n.typ.kind == tyTypeDesc:
|
||||||
result = n.typ.base
|
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:
|
else:
|
||||||
localError(n.info, errTypeExpected, n.renderTree)
|
localError(n.info, errTypeExpected, n.renderTree)
|
||||||
result = errorType(c)
|
result = errorType(c)
|
||||||
|
|
@ -1177,7 +1181,7 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType =
|
||||||
else:
|
else:
|
||||||
localError(n.info, errGenerated, "invalid type")
|
localError(n.info, errGenerated, "invalid type")
|
||||||
elif n[0].kind notin nkIdentKinds:
|
elif n[0].kind notin nkIdentKinds:
|
||||||
result = semTypeExpr(c, n)
|
result = semTypeExpr(c, n, prev)
|
||||||
else:
|
else:
|
||||||
let op = considerQuotedIdent(n.sons[0])
|
let op = considerQuotedIdent(n.sons[0])
|
||||||
if op.id in {ord(wAnd), ord(wOr)} or op.s == "|":
|
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})
|
let typExpr = semExprWithType(c, n.sons[1], {efInTypeof})
|
||||||
result = typExpr.typ
|
result = typExpr.typ
|
||||||
else:
|
else:
|
||||||
result = semTypeExpr(c, n)
|
result = semTypeExpr(c, n, prev)
|
||||||
of nkWhenStmt:
|
of nkWhenStmt:
|
||||||
var whenResult = semWhen(c, n, false)
|
var whenResult = semWhen(c, n, false)
|
||||||
if whenResult.kind == nkStmtList: whenResult.kind = nkStmtListType
|
if whenResult.kind == nkStmtList: whenResult.kind = nkStmtListType
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue