]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Properly set CodeNode.error when reporting an error
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 10 Feb 2020 09:42:41 +0000 (10:42 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 10 Feb 2020 14:15:01 +0000 (15:15 +0100)
14 files changed:
vala/valaarraytype.vala
vala/valaassignment.vala
vala/valabinaryexpression.vala
vala/valacastexpression.vala
vala/valacreationmethod.vala
vala/valadeclarationstatement.vala
vala/valadelegatetype.vala
vala/valadeletestatement.vala
vala/valalocalvariable.vala
vala/valamethod.vala
vala/valaobjecttype.vala
vala/valaparameter.vala
vala/valapropertyaccessor.vala
vala/valasignal.vala

index bc5eb16d78edea6bf952240d8680d88c52eec813..bb6dceb4465a9db87fcab092420512e759eca37d 100644 (file)
@@ -290,17 +290,20 @@ public class Vala.ArrayType : ReferenceType {
                        length.check (context);
 
                        if (length.value_type == null || !(length.value_type is IntegerType) || !length.is_constant ()) {
+                               error = true;
                                Report.error (length.source_reference, "Expression of constant integer type expected");
                                return false;
                        }
                }
 
                if (element_type is ArrayType) {
+                       error = true;
                        Report.error (source_reference, "Stacked arrays are not supported");
                        return false;
                } else if (element_type is DelegateType) {
                        var delegate_type = (DelegateType) element_type;
                        if (delegate_type.delegate_symbol.has_target) {
+                               error = true;
                                Report.error (source_reference, "Delegates with target are not supported as array element type");
                                return false;
                        }
index 9b5c7da5b46d4f90ad5dad0bccba786aa201a723..72f150314027cd7e3e0950b5f148047ccaf02a45 100644 (file)
@@ -283,9 +283,11 @@ public class Vala.Assignment : Expression {
                                           && context.analyzer.find_current_method () is CreationMethod) {
                                        if (ma.inner.symbol_reference != context.analyzer.find_current_method ().this_parameter) {
                                                // trying to set construct-only property in creation method for foreign instance
+                                               error = true;
                                                Report.error (ma.source_reference, "Property `%s' is read-only".printf (prop.get_full_name ()));
                                                return false;
                                        } else {
+                                               error = true;
                                                Report.error (ma.source_reference, "Cannot assign to construct-only properties, use Object (property: value) constructor chain up");
                                                return false;
                                        }
index 7056350334d02a91b32b0277567da5162740e59c..60c91167770c112f6ff9419050ff289354994b24 100644 (file)
@@ -570,6 +570,7 @@ public class Vala.BinaryExpression : Expression {
                                right.target_type.nullable = false;
                        } else if (right.value_type is ArrayType) {
                                if (!left.value_type.compatible (((ArrayType) right.value_type).element_type)) {
+                                       error = true;
                                        Report.error (source_reference, "Cannot look for `%s' in `%s'".printf (left.value_type.to_string (), right.value_type.to_string ()));
                                }
                        } else {
index 1a1e6ad05f4a481a9f1d733a4b660c5055e539ad..5dc5dc3e66fcaa8e47271d6b3c7f4913c5a8595f 100644 (file)
@@ -185,6 +185,7 @@ public class Vala.CastExpression : Expression {
                        // GVariant unboxing returns owned value
                        value_type.value_owned = true;
                        if (value_type.get_type_signature () == null) {
+                               error = true;
                                Report.error (source_reference, "Casting of `GLib.Variant' to `%s' is not supported".printf (value_type.to_qualified_string ()));
                        }
                }
index 89db56abe4b696a6fc836b74dfdd0307a2849650..23d40fd393e33327c0fb191d80482b336a7064a3 100644 (file)
@@ -176,6 +176,7 @@ public class Vala.CreationMethod : Method {
                context.analyzer.current_symbol = old_symbol;
 
                if (is_abstract || is_virtual || overrides) {
+                       error = true;
                        Report.error (source_reference, "The creation method `%s' cannot be marked as override, virtual, or abstract".printf (get_full_name ()));
                        return false;
                }
index e103024138d00f15d38e51e0fd2b435a3bf3d075..459489cedb88aee36af523b1b50a85b8d34729a5 100644 (file)
@@ -79,7 +79,11 @@ public class Vala.DeclarationStatement : CodeNode, Statement {
 
                checked = true;
 
-               declaration.check (context);
+               if (!declaration.check (context)) {
+                       // ignore inner error
+                       error = true;
+                       return false;
+               }
 
                return !error;
        }
index 2c5efb91199b08b548cb5852b51a81083d9049fb..4029f00affee4b0598468961bf9d0d16cb1193b0 100644 (file)
@@ -102,15 +102,18 @@ public class Vala.DelegateType : CallableType {
                var n_type_params = delegate_symbol.get_type_parameters ().size;
                var n_type_args = get_type_arguments ().size;
                if (n_type_args > 0 && n_type_args < n_type_params) {
+                       error = true;
                        Report.error (source_reference, "too few type arguments");
                        return false;
                } else if (n_type_args > 0 && n_type_args > n_type_params) {
+                       error = true;
                        Report.error (source_reference, "too many type arguments");
                        return false;
                }
 
                foreach (DataType type in get_type_arguments ()) {
                        if (!type.check (context)) {
+                               error = true;
                                return false;
                        }
                }
index ff3ff68913f507d03fd53fcc05e26d359acefdfe..eb1d9215054a1342b2655733021ad338b9d2a296 100644 (file)
@@ -65,6 +65,7 @@ public class Vala.DeleteStatement : CodeNode, Statement {
 
                if (!expression.check (context)) {
                        // if there was an error in the inner expression, skip this check
+                       error = true;
                        return false;
                }
 
index fac3bc41c244a0554b35f8cbccc8f72a6ee6a3df..a6a1a884214971add902cee17d22f9fe0ad280d1 100644 (file)
@@ -163,6 +163,7 @@ public class Vala.LocalVariable : Variable {
 
                if (variable_array_type != null && variable_array_type.inline_allocated
                    && variable_array_type.length == null && !(initializer is ArrayCreationExpression)) {
+                       error = true;
                        Report.error (source_reference, "Inline allocated array requires either a given length or an initializer");
                }
 
index f5b22131ab5a56224a1330a99b1dce4f5c01c620..81788830905e09fba5ccde4f0aad280ccbdfb617 100644 (file)
@@ -766,12 +766,16 @@ public class Vala.Method : Subroutine, Callable {
                }
 
                if (is_abstract && body != null) {
+                       error = true;
                        Report.error (source_reference, "Abstract methods cannot have bodies");
                } else if ((is_abstract || is_virtual) && is_extern) {
+                       error = true;
                        Report.error (source_reference, "Extern methods cannot be abstract or virtual");
                } else if (is_extern && body != null) {
+                       error = true;
                        Report.error (source_reference, "Extern methods cannot have bodies");
                } else if (!is_abstract && !external && source_type == SourceFileType.SOURCE && body == null) {
+                       error = true;
                        Report.error (source_reference, "Non-abstract, non-extern methods must have bodies");
                }
 
@@ -849,6 +853,7 @@ public class Vala.Method : Subroutine, Callable {
                        // Add local variable to provide access to params arrays which will be constructed out of the given va-args
                        if (param.params_array && body != null) {
                                if (params_array_var != null) {
+                                       error = true;
                                        Report.error (param.source_reference, "Only one params-array parameter is allowed");
                                        continue;
                                }
@@ -859,9 +864,11 @@ public class Vala.Method : Subroutine, Callable {
                                type.element_type.value_owned = type.value_owned;
                                type.value_owned = true;
                                if (type.element_type.is_real_struct_type () && !type.element_type.nullable) {
+                                       error = true;
                                        Report.error (param.source_reference, "Only nullable struct elements are supported in params-array");
                                }
                                if (type.length != null) {
+                                       error = true;
                                        Report.error (param.source_reference, "Passing length to params-array is not supported yet");
                                }
                                params_array_var = new LocalVariable (type, param.name, null, param.source_reference);
@@ -1049,14 +1056,17 @@ public class Vala.Method : Subroutine, Callable {
                        context.entry_point = this;
 
                        if (tree_can_fail) {
+                               error = true;
                                Report.error (source_reference, "\"main\" method cannot throw errors");
                        }
 
                        if (is_inline) {
+                               error = true;
                                Report.error (source_reference, "\"main\" method cannot be inline");
                        }
 
                        if (coroutine) {
+                               error = true;
                                Report.error (source_reference, "\"main\" method cannot be async");
                        }
                }
index 154fa3872adf4a64463e01049dac495e062f59d6..53101926c4bdbe45859953d29151ff68e03e8166 100644 (file)
@@ -105,9 +105,11 @@ public class Vala.ObjectType : ReferenceType {
 
                int n_type_args = get_type_arguments ().size;
                if (n_type_args > 0 && n_type_args < object_type_symbol.get_type_parameters ().size) {
+                       error = true;
                        Report.error (source_reference, "too few type arguments");
                        return false;
                } else if (n_type_args > 0 && n_type_args > object_type_symbol.get_type_parameters ().size) {
+                       error = true;
                        Report.error (source_reference, "too many type arguments");
                        return false;
                }
index 9c698458b8193d2ca1bd76505d07f6338a80e561..e447612d36b712c37e9c73b5d4bfaa165f1609e7 100644 (file)
@@ -171,6 +171,7 @@ public class Vala.Parameter : Variable {
                        unowned ArrayType? variable_array_type = variable_type as ArrayType;
                        if (variable_array_type != null && variable_array_type.inline_allocated
                                && !variable_array_type.fixed_length) {
+                               error = true;
                                Report.error (source_reference, "Inline allocated array as parameter requires to have fixed length");
                        }
                }
@@ -181,12 +182,16 @@ public class Vala.Parameter : Variable {
                            && direction != ParameterDirection.OUT) {
                                Report.warning (source_reference, "`null' incompatible with parameter type `%s'".printf (variable_type.to_string ()));
                        } else if (!(initializer is NullLiteral) && direction == ParameterDirection.OUT) {
+                               error = true;
                                Report.error (source_reference, "only `null' is allowed as default value for out parameters");
                        } else if (direction == ParameterDirection.IN && !initializer.value_type.compatible (variable_type)) {
+                               error = true;
                                Report.error (initializer.source_reference, "Cannot convert from `%s' to `%s'".printf (initializer.value_type.to_string (), variable_type.to_string ()));
                        } else if (direction == ParameterDirection.REF) {
+                               error = true;
                                Report.error (source_reference, "default value not allowed for ref parameter");
                        } else if (!initializer.is_accessible (this)) {
+                               error = true;
                                Report.error (initializer.source_reference, "default value is less accessible than method `%s'".printf (parent_symbol.get_full_name ()));
                        }
                }
index 18ea71466f803646e4d1036b4ebd394d696f0c85..bb718470fab95f5c6a37801f20f8413e48d6bfcb 100644 (file)
@@ -170,6 +170,7 @@ public class Vala.PropertyAccessor : Subroutine {
                                        if (source_reference == null || source_reference.file == null) {
                                                // Hopefully good as is
                                        } else if (!value_type.value_owned && source_reference.file.file_type == SourceFileType.SOURCE) {
+                                               error = true;
                                                Report.error (source_reference, "unowned return value for getter of property `%s' not supported without accessor".printf (prop.get_full_name ()));
                                        }
                                } else if (value_type.value_owned && (source_reference == null || source_reference.file == null)) {
index f7b987994aa75c5478be9f04542fa7751926632e..a07a0f5d64a6c5606a38350f08003ddaffe00509 100644 (file)
@@ -223,6 +223,7 @@ public class Vala.Signal : Symbol, Callable {
                }
 
                if (!is_virtual && body != null) {
+                       error = true;
                        Report.error (source_reference, "Only virtual signals can have a default signal handler body");
                }