fix try catch statements without thrown exceptions, fixes bug 506016
authorJuerg Billeter <j@bitron.ch>
Fri, 29 Feb 2008 20:46:07 +0000 (20:46 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 29 Feb 2008 20:46:07 +0000 (20:46 +0000)
2008-02-29  Juerg Billeter  <j@bitron.ch>

* gobject/valaccodegenerator.vala: fix try catch statements without
  thrown exceptions, fixes bug 506016

* tests/exceptions.vala: test try catch statements without errors

svn path=/trunk/; revision=1065

ChangeLog
gobject/valaccodegenerator.vala
tests/exceptions.vala

index 8aaeac4..657d6d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2008-02-29  Jürg Billeter  <j@bitron.ch>
 
+       * gobject/valaccodegenerator.vala: fix try catch statements without
+         thrown exceptions, fixes bug 506016
+
+       * tests/exceptions.vala: test try catch statements without errors
+
+2008-02-29  Jürg Billeter  <j@bitron.ch>
+
        * gobject/valaccodegenerator.vala: support throw statements in try
          statements
 
index c0f2373..4457916 100644 (file)
@@ -1302,6 +1302,8 @@ public class Vala.CCodeGenerator : CodeGenerator {
        }
 
        private void add_simple_check (CodeNode! node, CCodeFragment! cfrag) {
+               current_method_inner_error = true;
+
                var cprint_frag = new CCodeFragment ();
                var ccritical = new CCodeFunctionCall (new CCodeIdentifier ("g_critical"));
                ccritical.add_argument (new CCodeConstant ("\"file %s: line %d: uncaught error: %s\""));
@@ -2160,6 +2162,8 @@ public class Vala.CCodeGenerator : CodeGenerator {
        }
 
        public override void visit_catch_clause (CatchClause! clause) {
+               current_method_inner_error = true;
+
                clause.accept_children (this);
 
                var cfrag = new CCodeFragment ();
index 7d22192..8e5ac27 100644 (file)
@@ -98,6 +98,13 @@ class Maman.Bar : Object {
                assert_not_reached ();
        }
 
+       static void test_try_without_error () {
+               try {
+               } catch (Error e) {
+                       assert_not_reached ();
+               }
+       }
+
        static int main (string[] args) {
                stdout.printf ("Exception Test: 1");