[vala/0.46] vala: Properly set CodeNode.error when reporting an error



commit 90940d2aff46351250ce592e48b2c50d36704c33
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Feb 10 10:42:41 2020 +0100

    vala: Properly set CodeNode.error when reporting an error

 vala/valaarraytype.vala            | 3 +++
 vala/valaassignment.vala           | 2 ++
 vala/valabinaryexpression.vala     | 1 +
 vala/valacastexpression.vala       | 1 +
 vala/valacreationmethod.vala       | 1 +
 vala/valadeclarationstatement.vala | 6 +++++-
 vala/valadelegatetype.vala         | 3 +++
 vala/valadeletestatement.vala      | 1 +
 vala/valalocalvariable.vala        | 1 +
 vala/valamethod.vala               | 7 +++++++
 vala/valaobjecttype.vala           | 2 ++
 vala/valaparameter.vala            | 5 +++++
 vala/valapropertyaccessor.vala     | 1 +
 vala/valasignal.vala               | 1 +
 14 files changed, 34 insertions(+), 1 deletion(-)
---
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index 84522ca4c..6ed9e085d 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -285,17 +285,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;
                        }
diff --git a/vala/valaassignment.vala b/vala/valaassignment.vala
index 0920a48fb..4171dd154 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -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;
                                        }
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index 32d5012b5..b85f6ffce 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -527,6 +527,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 {
diff --git a/vala/valacastexpression.vala b/vala/valacastexpression.vala
index 63e356155..2b8f0e880 100644
--- a/vala/valacastexpression.vala
+++ b/vala/valacastexpression.vala
@@ -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 ()));
                        }
                }
diff --git a/vala/valacreationmethod.vala b/vala/valacreationmethod.vala
index a3344818f..710d8e5cc 100644
--- a/vala/valacreationmethod.vala
+++ b/vala/valacreationmethod.vala
@@ -172,6 +172,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;
                }
diff --git a/vala/valadeclarationstatement.vala b/vala/valadeclarationstatement.vala
index ab652e906..8156f7fd4 100644
--- a/vala/valadeclarationstatement.vala
+++ b/vala/valadeclarationstatement.vala
@@ -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;
        }
diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala
index 0220b0168..2130f3f7e 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -128,15 +128,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;
                        }
                }
diff --git a/vala/valadeletestatement.vala b/vala/valadeletestatement.vala
index ff3ff6891..eb1d92150 100644
--- a/vala/valadeletestatement.vala
+++ b/vala/valadeletestatement.vala
@@ -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;
                }
 
diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala
index c3a3ec82e..e350413f9 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -155,6 +155,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");
                }
 
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 5dd00fec3..880d46064 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -760,12 +760,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");
                }
 
@@ -1018,14 +1022,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");
                        }
                }
diff --git a/vala/valaobjecttype.vala b/vala/valaobjecttype.vala
index 4683f2081..06444babc 100644
--- a/vala/valaobjecttype.vala
+++ b/vala/valaobjecttype.vala
@@ -102,9 +102,11 @@ public class Vala.ObjectType : ReferenceType {
 
                int n_type_args = get_type_arguments ().size;
                if (n_type_args > 0 && n_type_args < 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 > type_symbol.get_type_parameters ().size) {
+                       error = true;
                        Report.error (source_reference, "too many type arguments");
                        return false;
                }
diff --git a/vala/valaparameter.vala b/vala/valaparameter.vala
index 781f4f0e0..3f382595a 100644
--- a/vala/valaparameter.vala
+++ b/vala/valaparameter.vala
@@ -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 ()));
                        }
                }
diff --git a/vala/valapropertyaccessor.vala b/vala/valapropertyaccessor.vala
index d98aebc3a..8ef737280 100644
--- a/vala/valapropertyaccessor.vala
+++ b/vala/valapropertyaccessor.vala
@@ -166,6 +166,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)) {
diff --git a/vala/valasignal.vala b/vala/valasignal.vala
index de0bd1f04..2881c3b2f 100644
--- a/vala/valasignal.vala
+++ b/vala/valasignal.vala
@@ -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");
                }
 


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