[vala/0.40] vala: Properly set CodeNode.error when reporting an error
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] vala: Properly set CodeNode.error when reporting an error
- Date: Thu, 5 Mar 2020 18:44:02 +0000 (UTC)
commit 71566422c336264134c2bc199fdf04c8197750d2
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/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/valasignal.vala | 1 +
12 files changed, 32 insertions(+), 1 deletion(-)
---
diff --git a/vala/valaarraytype.vala b/vala/valaarraytype.vala
index ea8cde2d5..21941e3e4 100644
--- a/vala/valaarraytype.vala
+++ b/vala/valaarraytype.vala
@@ -266,17 +266,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 11b7bfedb..38f63ea1f 100644
--- a/vala/valaassignment.vala
+++ b/vala/valaassignment.vala
@@ -339,9 +339,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 356347152..83bb90228 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -546,6 +546,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/valacreationmethod.vala b/vala/valacreationmethod.vala
index 86d6b013d..114bbf8c3 100644
--- a/vala/valacreationmethod.vala
+++ b/vala/valacreationmethod.vala
@@ -167,6 +167,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 f0a3d4161..9d74a57f5 100644
--- a/vala/valadeclarationstatement.vala
+++ b/vala/valadeclarationstatement.vala
@@ -69,7 +69,11 @@ public class Vala.DeclarationStatement : CodeNode, Statement {
checked = true;
- declaration.check (context);
+ if (!declaration.check (context)) {
+ // ignore inner error
+ error = true;
+ return false;
+ }
var local = declaration as LocalVariable;
if (local != null && local.initializer != null) {
diff --git a/vala/valadelegatetype.vala b/vala/valadelegatetype.vala
index 8e62d750b..aa0fa68cf 100644
--- a/vala/valadelegatetype.vala
+++ b/vala/valadelegatetype.vala
@@ -124,15 +124,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 8654a982b..fed098cf5 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -139,6 +139,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 1fdd782e4..096429348 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -687,12 +687,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) && external && !external_package &&
!parent_symbol.external) {
+ error = true;
Report.error (source_reference, "Extern methods cannot be abstract or virtual");
} else if (external && 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");
}
@@ -922,14 +926,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 eccdbbddf..a9955c697 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 a211345f4..aad777774 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/valasignal.vala b/vala/valasignal.vala
index c2fbd8c91..e40359811 100644
--- a/vala/valasignal.vala
+++ b/vala/valasignal.vala
@@ -211,6 +211,7 @@ public class Vala.Signal : Symbol, Lockable, 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]