* fixes #10203 * make typredef test green again * fixes the regressions differently
This commit is contained in:
parent
06a8b48811
commit
05c52ff34f
3 changed files with 34 additions and 16 deletions
|
|
@ -1318,7 +1318,19 @@ proc semGeneric(c: PContext, n: PNode, s: PSym, prev: PType): PType =
|
||||||
if tx != result and tx.kind == tyObject and tx.sons[0] != nil:
|
if tx != result and tx.kind == tyObject and tx.sons[0] != nil:
|
||||||
semObjectTypeForInheritedGenericInst(c, n, tx)
|
semObjectTypeForInheritedGenericInst(c, n, tx)
|
||||||
|
|
||||||
proc maybeAliasType(c: PContext; typeExpr, prev: PType): PType
|
proc maybeAliasType(c: PContext; typeExpr, prev: PType): PType =
|
||||||
|
if typeExpr.kind in {tyObject, tyEnum, tyDistinct, tyForward} and prev != nil:
|
||||||
|
result = newTypeS(tyAlias, c)
|
||||||
|
result.rawAddSon typeExpr
|
||||||
|
result.sym = prev.sym
|
||||||
|
assignType(prev, result)
|
||||||
|
|
||||||
|
proc fixupTypeOf(c: PContext, prev: PType, typExpr: PNode) =
|
||||||
|
if prev != nil:
|
||||||
|
let result = newTypeS(tyAlias, c)
|
||||||
|
result.rawAddSon typExpr.typ
|
||||||
|
result.sym = prev.sym
|
||||||
|
assignType(prev, result)
|
||||||
|
|
||||||
proc semTypeExpr(c: PContext, n: PNode; prev: PType): PType =
|
proc semTypeExpr(c: PContext, n: PNode; prev: PType): PType =
|
||||||
var n = semExprWithType(c, n, {efDetermineType})
|
var n = semExprWithType(c, n, {efDetermineType})
|
||||||
|
|
@ -1422,20 +1434,6 @@ proc semProcTypeWithScope(c: PContext, n: PNode,
|
||||||
when useEffectSystem: setEffectsForProcType(c.graph, result, n.sons[1])
|
when useEffectSystem: setEffectsForProcType(c.graph, result, n.sons[1])
|
||||||
closeScope(c)
|
closeScope(c)
|
||||||
|
|
||||||
proc maybeAliasType(c: PContext; typeExpr, prev: PType): PType =
|
|
||||||
if typeExpr.kind in {tyObject, tyEnum, tyDistinct} and prev != nil:
|
|
||||||
result = newTypeS(tyAlias, c)
|
|
||||||
result.rawAddSon typeExpr
|
|
||||||
result.sym = prev.sym
|
|
||||||
assignType(prev, result)
|
|
||||||
|
|
||||||
proc fixupTypeOf(c: PContext, prev: PType, typExpr: PNode) =
|
|
||||||
if prev != nil:
|
|
||||||
let result = newTypeS(tyAlias, c)
|
|
||||||
result.rawAddSon typExpr.typ
|
|
||||||
result.sym = prev.sym
|
|
||||||
assignType(prev, result)
|
|
||||||
|
|
||||||
proc symFromExpectedTypeNode(c: PContext, n: PNode): PSym =
|
proc symFromExpectedTypeNode(c: PContext, n: PNode): PSym =
|
||||||
if n.kind == nkType:
|
if n.kind == nkType:
|
||||||
result = symFromType(c, n.typ, n.info)
|
result = symFromType(c, n.typ, n.info)
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,7 @@ proc typeToString(typ: PType, prefer: TPreferedDesc = preferName): string =
|
||||||
sfAnon notin t.sym.flags:
|
sfAnon notin t.sym.flags:
|
||||||
if t.kind == tyInt and isIntLit(t):
|
if t.kind == tyInt and isIntLit(t):
|
||||||
result = t.sym.name.s & " literal(" & $t.n.intVal & ")"
|
result = t.sym.name.s & " literal(" & $t.n.intVal & ")"
|
||||||
elif t.kind == tyAlias:
|
elif t.kind == tyAlias and t.sons[0].kind != tyAlias:
|
||||||
result = typeToString(t.sons[0])
|
result = typeToString(t.sons[0])
|
||||||
elif prefer in {preferName, preferTypeName} or t.sym.owner.isNil:
|
elif prefer in {preferName, preferTypeName} or t.sym.owner.isNil:
|
||||||
result = t.sym.name.s
|
result = t.sym.name.s
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,23 @@ suite "object basic methods":
|
||||||
check($obj == "(foo: 1)")
|
check($obj == "(foo: 1)")
|
||||||
test "it should test equality based on fields":
|
test "it should test equality based on fields":
|
||||||
check(makeObj(1) == makeObj(1))
|
check(makeObj(1) == makeObj(1))
|
||||||
|
|
||||||
|
# bug #10203
|
||||||
|
|
||||||
|
type
|
||||||
|
TMyObj = TYourObj
|
||||||
|
TYourObj = object of RootObj
|
||||||
|
x, y: int
|
||||||
|
|
||||||
|
proc init: TYourObj =
|
||||||
|
result.x = 0
|
||||||
|
result.y = -1
|
||||||
|
|
||||||
|
proc f(x: var TYourObj) =
|
||||||
|
discard
|
||||||
|
|
||||||
|
var m: TMyObj = init()
|
||||||
|
f(m)
|
||||||
|
|
||||||
|
var a: TYourObj = m
|
||||||
|
var b: TMyObj = a
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue