[vala/0.42] codegen: Replace some unfortunate asserts with internal error reports



commit 6f1504fae9456cb460c6ca58e80d5ef7e08e0137
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Jan 23 21:36:12 2019 +0100

    codegen: Replace some unfortunate asserts with internal error reports

 codegen/valaccodebasemodule.vala   | 6 ++++--
 codegen/valaccodemethodmodule.vala | 3 ++-
 codegen/valagtypemodule.vala       | 4 ++--
 3 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 32ca7f349..519fd8589 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -5618,14 +5618,16 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                                        } else if (cleft is CCodeConstant) {
                                                left = ((CCodeConstant) cleft).name;
                                        } else {
-                                               assert_not_reached ();
+                                               Report.error (expr.source_reference, "internal: Unsupported 
expression");
+                                               left = "NULL";
                                        }
                                        if (cright is CCodeIdentifier) {
                                                right = ((CCodeIdentifier) cright).name;
                                        } else if (cright is CCodeConstant) {
                                                right = ((CCodeConstant) cright).name;
                                        } else {
-                                               assert_not_reached ();
+                                               Report.error (expr.source_reference, "internal: Unsupported 
expression");
+                                               right = "NULL";
                                        }
 
                                        set_cvalue (expr, new CCodeConstant ("%s %s".printf (left, right)));
diff --git a/codegen/valaccodemethodmodule.vala b/codegen/valaccodemethodmodule.vala
index 23113c3c7..0c8dbe25a 100644
--- a/codegen/valaccodemethodmodule.vala
+++ b/codegen/valaccodemethodmodule.vala
@@ -951,7 +951,8 @@ public abstract class Vala.CCodeMethodModule : CCodeStructModule {
                        } else if (parent_type is Enum) {
                                this_type = new EnumValueType ((Enum) parent_type);
                        } else {
-                               assert_not_reached ();
+                               Report.error (parent_type.source_reference, "internal: Unsupported symbol 
type");
+                               this_type = new InvalidType ();
                        }
 
                        generate_type_declaration (this_type, decl_space);
diff --git a/codegen/valagtypemodule.vala b/codegen/valagtypemodule.vala
index 603590aff..a654c0197 100644
--- a/codegen/valagtypemodule.vala
+++ b/codegen/valagtypemodule.vala
@@ -257,7 +257,7 @@ public class Vala.GTypeModule : GErrorModule {
                                        var f = (Field) s;
                                        generate_struct_field_declaration (cl, f, instance_struct, 
type_struct, decl_space, ref has_struct_member);
                                } else {
-                                       assert_not_reached ();
+                                       Report.error (s.source_reference, "internal: Unsupported symbol");
                                }
                        }
                } else {
@@ -2180,7 +2180,7 @@ public class Vala.GTypeModule : GErrorModule {
                                        type_struct.add_declaration (vdecl);
                                }
                        } else {
-                               assert_not_reached ();
+                               Report.error (sym.source_reference, "internal: Unsupported symbol");
                        }
                }
 


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