Add missing ShallowClone implementation for SetType

It turns out that SetType was missing a ShallowClone implementation.
Which meant that when a SetType was cloned, a TableType was received
(which has one less member). Which resulted in invalid memory accesses
when using the clone.

Thank you valgrind :)
This commit is contained in:
Johanna Amann 2019-06-18 14:37:09 -07:00
parent 5365d60202
commit 53cde131e9
2 changed files with 15 additions and 0 deletions

View file

@ -484,6 +484,19 @@ SetType::SetType(TypeList* ind, ListExpr* arg_elements) : TableType(ind, 0)
} }
} }
SetType* SetType::ShallowClone()
{
// constructor only consumes indices when elements
// is set
if ( elements && indices )
{
elements->Ref();
indices->Ref();
}
return new SetType(indices, elements);
}
SetType::~SetType() SetType::~SetType()
{ {
Unref(elements); Unref(elements);

View file

@ -381,6 +381,8 @@ public:
SetType(TypeList* ind, ListExpr* arg_elements); SetType(TypeList* ind, ListExpr* arg_elements);
~SetType() override; ~SetType() override;
SetType* ShallowClone() override;
ListExpr* SetElements() const { return elements; } ListExpr* SetElements() const { return elements; }
protected: protected: