fixes #5137
This commit is contained in:
parent
4e481cc316
commit
7bd473c59b
2 changed files with 28 additions and 14 deletions
|
|
@ -122,18 +122,27 @@ proc typeName(typ: PType): Rope =
|
||||||
else:
|
else:
|
||||||
~"TY"
|
~"TY"
|
||||||
|
|
||||||
|
const
|
||||||
|
irrelevantForBackend = {tyGenericBody, tyGenericInst, tyGenericInvocation,
|
||||||
|
tyDistinct, tyRange, tyStatic, tyAlias}
|
||||||
|
|
||||||
proc getTypeName(m: BModule; typ: PType; sig: SigHash): Rope =
|
proc getTypeName(m: BModule; typ: PType; sig: SigHash): Rope =
|
||||||
let typ = if typ.kind == tyAlias: typ.lastSon else: typ
|
var typ = typ
|
||||||
if typ.sym != nil and {sfImportc, sfExportc} * typ.sym.flags != {}:
|
while true:
|
||||||
result = typ.sym.loc.r
|
if typ.sym != nil and {sfImportc, sfExportc} * typ.sym.flags != {}:
|
||||||
else:
|
return typ.sym.loc.r
|
||||||
if typ.loc.r == nil:
|
|
||||||
typ.loc.r = typ.typeName & $sig
|
if typ.kind in irrelevantForBackend:
|
||||||
|
typ = typ.lastSon
|
||||||
else:
|
else:
|
||||||
when defined(debugSigHashes):
|
break
|
||||||
# check consistency:
|
if typ.loc.r == nil:
|
||||||
assert($typ.loc.r == $(typ.typeName & $sig))
|
typ.loc.r = typ.typeName & $sig
|
||||||
result = typ.loc.r
|
else:
|
||||||
|
when defined(debugSigHashes):
|
||||||
|
# check consistency:
|
||||||
|
assert($typ.loc.r == $(typ.typeName & $sig))
|
||||||
|
result = typ.loc.r
|
||||||
if result == nil: internalError("getTypeName: " & $typ.kind)
|
if result == nil: internalError("getTypeName: " & $typ.kind)
|
||||||
|
|
||||||
proc mapSetType(typ: PType): TCTypeKind =
|
proc mapSetType(typ: PType): TCTypeKind =
|
||||||
|
|
@ -574,10 +583,6 @@ proc resolveStarsInCppType(typ: PType, idx, stars: int): PType =
|
||||||
result = if result.kind == tyGenericInst: result.sons[1]
|
result = if result.kind == tyGenericInst: result.sons[1]
|
||||||
else: result.elemType
|
else: result.elemType
|
||||||
|
|
||||||
const
|
|
||||||
irrelevantForBackend = {tyGenericBody, tyGenericInst, tyGenericInvocation,
|
|
||||||
tyDistinct, tyRange, tyStatic, tyAlias}
|
|
||||||
|
|
||||||
proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
|
proc getTypeDescAux(m: BModule, origTyp: PType, check: var IntSet): Rope =
|
||||||
# returns only the type's name
|
# returns only the type's name
|
||||||
var t = origTyp.skipTypes(irrelevantForBackend)
|
var t = origTyp.skipTypes(irrelevantForBackend)
|
||||||
|
|
|
||||||
|
|
@ -65,3 +65,12 @@ type
|
||||||
|
|
||||||
# have a proc taking TFlags as param and returning object having TFlags field
|
# have a proc taking TFlags as param and returning object having TFlags field
|
||||||
proc foo(flags: TFlags): TObj = nil
|
proc foo(flags: TFlags): TObj = nil
|
||||||
|
|
||||||
|
|
||||||
|
# bug #5137
|
||||||
|
type
|
||||||
|
MyInt {.importc: "int".} = object
|
||||||
|
MyIntDistinct = distinct MyInt
|
||||||
|
|
||||||
|
proc bug5137(d: MyIntDistinct) =
|
||||||
|
discard d.MyInt
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue