fixes another sighashes problem
This commit is contained in:
parent
00a230e5d8
commit
eae1aaa377
3 changed files with 31 additions and 5 deletions
|
|
@ -87,6 +87,7 @@ type
|
||||||
CoProc
|
CoProc
|
||||||
CoType
|
CoType
|
||||||
CoOwnerSig
|
CoOwnerSig
|
||||||
|
CoIgnoreRange
|
||||||
|
|
||||||
proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag])
|
proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag])
|
||||||
|
|
||||||
|
|
@ -159,14 +160,15 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
discard
|
discard
|
||||||
c &= char(t.kind)
|
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyBool, tyChar, tyInt..tyUInt64:
|
of tyBool, tyChar, tyInt..tyUInt64:
|
||||||
# no canonicalization for integral types, so that e.g. ``pid_t`` is
|
# no canonicalization for integral types, so that e.g. ``pid_t`` is
|
||||||
# produced instead of ``NI``:
|
# produced instead of ``NI``:
|
||||||
|
c &= char(t.kind)
|
||||||
if t.sym != nil and {sfImportc, sfExportc} * t.sym.flags != {}:
|
if t.sym != nil and {sfImportc, sfExportc} * t.sym.flags != {}:
|
||||||
c.hashSym(t.sym)
|
c.hashSym(t.sym)
|
||||||
of tyObject, tyEnum:
|
of tyObject, tyEnum:
|
||||||
|
c &= char(t.kind)
|
||||||
if t.typeInst != nil:
|
if t.typeInst != nil:
|
||||||
assert t.typeInst.kind == tyGenericInst
|
assert t.typeInst.kind == tyGenericInst
|
||||||
for i in countup(1, sonsLen(t.typeInst) - 2):
|
for i in countup(1, sonsLen(t.typeInst) - 2):
|
||||||
|
|
@ -199,26 +201,35 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
if t.len > 0 and t.sons[0] != nil:
|
if t.len > 0 and t.sons[0] != nil:
|
||||||
hashType c, t.sons[0], flags
|
hashType c, t.sons[0], flags
|
||||||
of tyRef, tyPtr, tyGenericBody, tyVar:
|
of tyRef, tyPtr, tyGenericBody, tyVar:
|
||||||
|
c &= char(t.kind)
|
||||||
c.hashType t.lastSon, flags
|
c.hashType t.lastSon, flags
|
||||||
if tfVarIsPtr in t.flags: c &= ".varisptr"
|
if tfVarIsPtr in t.flags: c &= ".varisptr"
|
||||||
of tyFromExpr:
|
of tyFromExpr:
|
||||||
|
c &= char(t.kind)
|
||||||
c.hashTree(t.n)
|
c.hashTree(t.n)
|
||||||
of tyTuple:
|
of tyTuple:
|
||||||
|
c &= char(t.kind)
|
||||||
if t.n != nil and CoType notin flags:
|
if t.n != nil and CoType notin flags:
|
||||||
assert(sonsLen(t.n) == sonsLen(t))
|
assert(sonsLen(t.n) == sonsLen(t))
|
||||||
for i in countup(0, sonsLen(t.n) - 1):
|
for i in countup(0, sonsLen(t.n) - 1):
|
||||||
assert(t.n.sons[i].kind == nkSym)
|
assert(t.n.sons[i].kind == nkSym)
|
||||||
c &= t.n.sons[i].sym.name.s
|
c &= t.n.sons[i].sym.name.s
|
||||||
c &= ':'
|
c &= ':'
|
||||||
c.hashType(t.sons[i], flags)
|
c.hashType(t.sons[i], flags+{CoIgnoreRange})
|
||||||
c &= ','
|
c &= ','
|
||||||
else:
|
else:
|
||||||
for i in countup(0, sonsLen(t) - 1): c.hashType t.sons[i], flags
|
for i in countup(0, sonsLen(t) - 1): c.hashType t.sons[i], flags+{CoIgnoreRange}
|
||||||
of tyRange, tyStatic:
|
of tyRange:
|
||||||
#if CoType notin flags:
|
if CoIgnoreRange notin flags:
|
||||||
|
c &= char(t.kind)
|
||||||
|
c.hashTree(t.n)
|
||||||
|
c.hashType(t.sons[0], flags)
|
||||||
|
of tyStatic:
|
||||||
|
c &= char(t.kind)
|
||||||
c.hashTree(t.n)
|
c.hashTree(t.n)
|
||||||
c.hashType(t.sons[0], flags)
|
c.hashType(t.sons[0], flags)
|
||||||
of tyProc:
|
of tyProc:
|
||||||
|
c &= char(t.kind)
|
||||||
c &= (if tfIterator in t.flags: "iterator " else: "proc ")
|
c &= (if tfIterator in t.flags: "iterator " else: "proc ")
|
||||||
if CoProc in flags and t.n != nil:
|
if CoProc in flags and t.n != nil:
|
||||||
let params = t.n
|
let params = t.n
|
||||||
|
|
@ -237,6 +248,7 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
|
||||||
if tfThread in t.flags: c &= ".thread"
|
if tfThread in t.flags: c &= ".thread"
|
||||||
if tfVarargs in t.flags: c &= ".varargs"
|
if tfVarargs in t.flags: c &= ".varargs"
|
||||||
else:
|
else:
|
||||||
|
c &= char(t.kind)
|
||||||
for i in 0..<t.len: c.hashType(t.sons[i], flags)
|
for i in 0..<t.len: c.hashType(t.sons[i], flags)
|
||||||
if tfNotNil in t.flags and CoType notin flags: c &= "not nil"
|
if tfNotNil in t.flags and CoType notin flags: c &= "not nil"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,3 +85,16 @@ proc go() =
|
||||||
echo "vidx ", $vidx(hg, 1, 2, hiC)
|
echo "vidx ", $vidx(hg, 1, 2, hiC)
|
||||||
|
|
||||||
go()
|
go()
|
||||||
|
|
||||||
|
# another sighashes problem: In tuples we have to ignore ranges.
|
||||||
|
|
||||||
|
type
|
||||||
|
Position = tuple[x, y: int16]
|
||||||
|
n16 = range[0'i16..high(int16)]
|
||||||
|
|
||||||
|
proc print(pos: Position) =
|
||||||
|
echo $pos.x, ",", $pos.y
|
||||||
|
|
||||||
|
var x = 0.n16
|
||||||
|
var y = 0.n16
|
||||||
|
print((x, y))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
discard """
|
discard """
|
||||||
cmd: "nim cpp $file"
|
cmd: "nim cpp $file"
|
||||||
output: ""
|
output: ""
|
||||||
|
targets: "cpp"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
block: #5979
|
block: #5979
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue