diff options
Diffstat (limited to 'compiler')
-rwxr-xr-x | compiler/ccgexprs.nim | 5 | ||||
-rwxr-xr-x | compiler/ccgtypes.nim | 7 | ||||
-rwxr-xr-x | compiler/semtypes.nim | 5 |
3 files changed, 13 insertions, 4 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index d6666d88b..72d95c4c7 100755 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -1036,6 +1036,9 @@ proc genOf(p: BProc, x: PNode, typ: PType, d: var TLoc) = while (t.kind == tyObject) and (t.sons[0] != nil): app(r, ".Sup") t = skipTypes(t.sons[0], typedescInst) + if isObjLackingTypeField(t): + GlobalError(x.info, errGenerated, + "no 'of' operator available for pure objects") if nilCheck != nil: r = ropecg(p.module, "(($1) && #isObj($2.m_type, $3))", [nilCheck, r, genTypeInfo(p.module, dest)]) @@ -1597,7 +1600,7 @@ proc upConv(p: BProc, n: PNode, d: var TLoc) = var a: TLoc initLocExpr(p, n.sons[0], a) var dest = skipTypes(n.typ, abstractPtrs) - if optObjCheck in p.options and not isPureObject(dest): + if optObjCheck in p.options and not isObjLackingTypeField(dest): var r = rdLoc(a) var nilCheck: PRope = nil var t = skipTypes(a.t, abstractInst) diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 0ab4ff200..0495c33fb 100755 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -694,11 +694,14 @@ when false: var tmp = getNimType(m) appf(m.s[cfsTypeInit2], "$2 = &$1;$n", [tmp, name]) +proc isObjLackingTypeField(typ: PType): bool {.inline.} = + result = (typ.kind == tyObject) and ((tfFinal in typ.flags) and + (typ.sons[0] == nil) or isPureObject(typ)) + proc genTypeInfoAuxBase(m: BModule, typ: PType, name, base: PRope) = var nimtypeKind: int #allocMemTI(m, typ, name) - if (typ.kind == tyObject) and (tfFinal in typ.flags) and - (typ.sons[0] == nil): + if isObjLackingTypeField(typ): nimtypeKind = ord(tyPureObject) else: nimtypeKind = ord(typ.kind) diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index c41727b10..f3a76913d 100755 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -856,7 +856,10 @@ proc semTypeNode(c: PContext, n: PNode, prev: PType): PType = result = s.typ else: assignType(prev, s.typ) - prev.id = s.typ.id + # bugfix: keep the fresh id for aliases to integral types: + if s.typ.kind notin {tyBool, tyChar, tyInt..tyInt64, tyFloat..tyFloat128, + tyUInt..tyUInt64}: + prev.id = s.typ.id result = prev of nkSym: if n.sym.kind == skType and n.sym.typ != nil: |