+2007-08-08 Jürg Billeter <j@bitron.ch>
+
+ * vala/valasemanticanalyzer.vala, gobject/valacodegenerator.vala,
+ tests/test-033.out, tests/test-033.vala: support exceptions in foreach
+ collection expressions, fix test
+
2007-08-07 Mathias Hasselmann <mathias.hasselmann@gmx.de>
* tests/test-033.vala, tests/testrunner.sh: test exception handling when
ccoldecl.add_declarator (new CCodeVariableDeclarator.with_initializer (collection_backup.name, (CCodeExpression) stmt.collection.ccodenode));
cblock.add_statement (ccoldecl);
+ if (stmt.tree_can_fail && stmt.collection.can_fail) {
+ // exception handling
+ var cfrag = new CCodeFragment ();
+ add_simple_check (stmt.collection, cfrag);
+ cblock.add_statement (cfrag);
+ }
+
stmt.ccodenode = cblock;
if (stmt.collection.static_type.data_type is Array) {
-Exception Test: 1 2 3 4 5 6 7 8 9 10 11
+Exception Test: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
result.add (" FOO");
result.add (" BAR");
- throw new BarError.LIST (" 14");
+ throw new BarError.LIST (" 12");
return result;
}
try {
foreach (string s in list ()) {
- stdout.printf (" 11");
+ stdout.printf (" BAD");
stdout.printf (" %s", s);
- stdout.printf (" 12");
+ stdout.printf (" BAD");
}
} catch (BarError e) {
- stdout.printf (" 13");
+ stdout.printf (" 11");
stdout.printf ("%s", e.message);
- stdout.printf (" 15");
+ stdout.printf (" 13");
}
- stdout.printf (" 16");
+ stdout.printf (" 14");
}
static int main (string[] args) {
var bar = new Bar ();
bar.run ();
- stdout.printf (" 17\n");
+ stdout.printf (" 15\n");
return 0;
}
Report.error (stmt.source_reference, "Collection not iterable");
return;
}
+
+ stmt.tree_can_fail = stmt.collection.tree_can_fail || stmt.body.tree_can_fail;
}
public override void visit_end_return_statement (ReturnStatement! stmt) {