[vala/wip/issue/658: 46/48] Warn if anonymous delegate attribute is ambiguous
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/658: 46/48] Warn if anonymous delegate attribute is ambiguous
- Date: Sat, 31 Oct 2020 15:08:17 +0000 (UTC)
commit 0962d9cfce651e31c6662589303f455cd64eb578
Author: Nick Schrader <nick schrader mailbox org>
Date: Fri Oct 30 01:38:31 2020 -0300
Warn if anonymous delegate attribute is ambiguous
vala/valaparser.vala | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 4a41eb41d..056289961 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -3536,6 +3536,7 @@ public class Vala.Parser : CodeVisitor {
}
Parameter parse_parameter (Symbol? parent=null, Method? method=null) throws ParseError {
+ var begin_attrs = get_location ();
var attrs = parse_attributes ();
var begin = get_location ();
if (accept (TokenType.ELLIPSIS)) {
@@ -3565,8 +3566,18 @@ public class Vala.Parser : CodeVisitor {
pretty_direction = "out";
}
+ string id = parse_identifier ();
+
var possibly_delegate = type as DelegateType;
if (possibly_delegate != null && possibly_delegate.delegate_symbol.anonymous) {
+ if (attrs != null) {
+ var here = get_location ();
+ rollback (begin);
+ Report.warning (get_src (begin_attrs), "Ambiguous attribute: does it belong
to `%s` or parameter `%s`?"
+ .printf (possibly_delegate.to_prototype_string (), id));
+ rollback (here);
+ }
+
if (pretty_direction != null) {
Report.error (get_src (begin), "Anonymous delegates cannot be `" +
pretty_direction + "` parameters");
}
@@ -3580,8 +3591,6 @@ public class Vala.Parser : CodeVisitor {
}
}
- string id = parse_identifier ();
-
type = parse_inline_array_type (type);
var param = new Parameter (id, type, get_src (begin));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]