Fix unsound transform pass (#8633)
When a `var openArray[T]` function parameter goes trough the `transformAddrDeref` pass we may lose the `var` specifier, leading to nasty crashes at runtime.
This commit is contained in:
parent
9a7e6be62f
commit
c04404635b
4 changed files with 22 additions and 0 deletions
|
|
@ -369,6 +369,8 @@ proc transformAddrDeref(c: PTransf, n: PNode, a, b: TNodeKind): PTransNode =
|
|||
result = PTransNode(n.sons[0])
|
||||
if n.typ.skipTypes(abstractVar).kind != tyOpenArray:
|
||||
PNode(result).typ = n.typ
|
||||
elif n.typ.skipTypes(abstractInst).kind in {tyVar}:
|
||||
PNode(result).typ = toVar(PNode(result).typ)
|
||||
of nkHiddenStdConv, nkHiddenSubConv, nkConv:
|
||||
var m = n.sons[0].sons[1]
|
||||
if m.kind == a or m.kind == b:
|
||||
|
|
@ -377,6 +379,8 @@ proc transformAddrDeref(c: PTransf, n: PNode, a, b: TNodeKind): PTransNode =
|
|||
result = PTransNode(n.sons[0])
|
||||
if n.typ.skipTypes(abstractVar).kind != tyOpenArray:
|
||||
PNode(result).typ = n.typ
|
||||
elif n.typ.skipTypes(abstractInst).kind in {tyVar}:
|
||||
PNode(result).typ = toVar(PNode(result).typ)
|
||||
else:
|
||||
if n.sons[0].kind == a or n.sons[0].kind == b:
|
||||
# addr ( deref ( x )) --> x
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue