[vala/0.52] vala: Improve CodeWriter.visit_catch_clause()



commit 0bce626e636bc2010a9ac30290462d698cebd8ea
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Oct 23 15:27:12 2021 +0200

    vala: Improve CodeWriter.visit_catch_clause()
    
    Properly output general catch clause

 vala/valacodewriter.vala | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 3e651fd72..cb3bd998d 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -1217,9 +1217,12 @@ public class Vala.CodeWriter : CodeVisitor {
        }
 
        public override void visit_catch_clause (CatchClause clause) {
-               var type_name = clause.error_type == null ? "GLib.Error" : clause.error_type.to_string ();
-               var var_name = clause.variable_name == null ? "_" : clause.variable_name;
-               write_string (" catch (%s %s)".printf (type_name, var_name));
+               if (clause.variable_name != null) {
+                       var type_name = clause.error_type == null ? "GLib.Error" : 
clause.error_type.to_string ();
+                       write_string (" catch (%s %s)".printf (type_name, clause.variable_name));
+               } else {
+                       write_string (" catch");
+               }
                clause.body.accept (this);
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]