and not clearing "temp_ref_values" caused invalid references later.
Fixes https://gitlab.gnome.org/GNOME/vala/issues/80
requires_assert = true;
ccode.add_expression (cassert);
+
+ foreach (var value in temp_ref_values) {
+ ccode.add_expression (destroy_value (value));
+ }
+
+ temp_ref_values.clear ();
}
public unowned DataType? get_this_type () {
methods/parameter-ref-array-resize-captured.vala \
methods/parameter-ref-delegate.vala \
methods/parameter-ref-element-access.vala \
+ methods/preconditions-temp-variables.vala \
methods/prepostconditions.vala \
methods/prepostconditions-captured.vala \
methods/postconditions.vala \
+ methods/postconditions-temp-variables.vala \
methods/return-unowned-delegate.vala \
methods/same-name.vala \
methods/symbolresolution.vala \
--- /dev/null
+string foo () ensures (result.to_string () != "23") {
+ return 4711.to_string ();
+}
+
+string bar (bool b) ensures (result.to_string () != "4711") {
+ if (b) {
+ return 23.to_string ();
+ } else {
+ return 42.to_string ();
+ }
+}
+
+void main () {
+ assert (foo () == "4711");
+ assert (bar (true) == "23");
+ assert (bar (false) == "42");
+}
--- /dev/null
+string foo (int i) requires (i.to_string () == "23" || i.to_string () == "42") {
+ return i.to_string ();
+}
+
+void main () {
+ assert (foo (23) == "23");
+ assert (foo (42) == "42");
+}