Wrong assignment of struct properties
@ricotz
Submitted by Rico Tzschichholz Link to original bug (#658046)
Description
This sample snippet shows the problem:
using Gdk;
class Source { public Rectangle Prop { get; protected set; }
public Source () {
Prop = Rectangle () {x = 1, y = 1, width = 1, height = 1};
}
public Rectangle get_prop () {
Prop.x = 2;
Prop.y = 4;
Prop.width = 6;
Prop.height = 8;
return Prop;
}
}
public class Test { public static int main (string[] args) { var source = new Source (); var prop = source.get_prop (); print ("%i %i %i %i\n", prop.x, prop.y, prop.width, prop.height); return 0; } }
Generated code:
with Vala git:
void source_get_prop (Source* self, GdkRectangle* result) { GdkRectangle tmp0; GdkRectangle tmp1; GdkRectangle tmp2; GdkRectangle tmp3; GdkRectangle tmp4; g_return_if_fail (self != NULL); tmp0 = self->priv->_Prop; tmp0.x = 2; tmp1 = self->priv->_Prop; tmp1.y = 4; tmp2 = self->priv->_Prop; tmp2.width = 6; tmp3 = self->priv->_Prop; tmp3.height = 8; tmp4 = self->priv->_Prop; *result = tmp4; return; }
Output: 1 1 1 1
with Vala 0.12.1:
void source_get_prop (Source* self, GdkRectangle* result) { g_return_if_fail (self != NULL); self->priv->_Prop.x = 2; self->priv->_Prop.y = 4; self->priv->_Prop.width = 6; self->priv->_Prop.height = 8; *result = self->priv->_Prop; return; }
Output: 2 4 6 8
Version: 0.13.x