https://bugzilla.gnome.org/show_bug.cgi?id=736774
control-flow/bug661985.vala \
control-flow/bug665904.vala \
control-flow/bug691514.vala \
+ control-flow/bug736774-1.vala \
+ control-flow/bug736774-2.vala \
enums/enum_only.vala \
enums/enums.vala \
enums/flags.vala \
--- /dev/null
+bool success = false;
+
+class Foo : Object {
+ ~Foo() {
+ success = true;
+ }
+}
+
+Foo may_fail () throws Error {
+ return new Foo ();
+}
+
+void func (Foo foo) {
+}
+
+void main() {
+ try {
+ func (may_fail ());
+ } catch {
+ }
+
+ assert (success);
+}
--- /dev/null
+string* keep;
+
+string may_fail () throws GLib.Error {
+ string result = "test";
+ keep = result;
+ return (owned) result;
+}
+
+void main () {
+ try {
+ print (_("%s\n"), may_fail ());
+ } catch {
+ }
+
+ assert (keep != "test");
+}
public static Expression create_temp_access (LocalVariable local, DataType? target_type) {
Expression temp_access = new MemberAccess.simple (local.name, local.source_reference);
- var target_owned = target_type == null || target_type.value_owned;
+ var target_owned = target_type != null && target_type.value_owned;
if (target_owned && local.variable_type.is_disposable ()) {
temp_access = new ReferenceTransferExpression (temp_access, local.source_reference);
temp_access.target_type = target_type != null ? target_type.copy () : local.variable_type.copy ();