diff options
author | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-02-10 10:42:41 +0100 |
---|---|---|
committer | Rico Tzschichholz <ricotz@ubuntu.com> | 2020-02-10 15:15:01 +0100 |
commit | cfacb6554cf14b551c4c3a3b6ac835d13599df2e (patch) | |
tree | 51e995d51272787b78af4ddf62f31aed24e0a33f /vala/valamethod.vala | |
parent | db50076daacc27a5d2376c5c549ba20a79e03e04 (diff) | |
download | vala-cfacb6554cf14b551c4c3a3b6ac835d13599df2e.tar.gz |
vala: Properly set CodeNode.error when reporting an error
Diffstat (limited to 'vala/valamethod.vala')
-rw-r--r-- | vala/valamethod.vala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/vala/valamethod.vala b/vala/valamethod.vala index f5b22131a..817888309 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -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"); } } |