[vala/staging] parser: Minor semantic checks to improve error messages
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] parser: Minor semantic checks to improve error messages
- Date: Thu, 15 Apr 2021 14:50:32 +0000 (UTC)
commit cbc11c2674209c3c51eb5c9851863dacea13366b
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Apr 15 16:49:14 2021 +0200
parser: Minor semantic checks to improve error messages
vala/valaparser.vala | 15 +++++++++++++++
1 file changed, 15 insertions(+)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index bad086982..cba7c51b2 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2497,12 +2497,18 @@ public class Vala.Parser : CodeVisitor {
case TokenType.CONSTRUCT:
if (context.profile == Profile.GOBJECT) {
rollback (begin);
+ if (!(parent is TypeSymbol)) {
+ throw new ParseError.SYNTAX ("unexpected `construct' declaration");
+ }
parse_constructor_declaration (parent, attrs);
return;
}
break;
case TokenType.TILDE:
rollback (begin);
+ if (!(parent is TypeSymbol)) {
+ throw new ParseError.SYNTAX ("unexpected `destructor' declaration");
+ }
parse_destructor_declaration (parent, attrs);
return;
case TokenType.OPEN_BRACE:
@@ -2581,6 +2587,9 @@ public class Vala.Parser : CodeVisitor {
break;
case TokenType.OPEN_PARENS:
rollback (begin);
+ if (!(parent is TypeSymbol)) {
+ throw new ParseError.SYNTAX ("unexpected `constructor' declaration");
+ }
parse_creation_method_declaration (parent, attrs);
return;
default:
@@ -2593,6 +2602,9 @@ public class Vala.Parser : CodeVisitor {
parse_delegate_declaration (parent, attrs);
return;
case TokenType.SIGNAL:
+ if (!(parent is ObjectTypeSymbol)) {
+ throw new ParseError.SYNTAX ("unexpected `signal'
declaration");
+ }
parse_signal_declaration (parent, attrs);
return;
default:
@@ -2613,6 +2625,9 @@ public class Vala.Parser : CodeVisitor {
case TokenType.OPEN_BRACE:
case TokenType.THROWS:
rollback (begin);
+ if (!(parent is TypeSymbol)) {
+ throw new ParseError.SYNTAX ("unexpected `property'
declaration");
+ }
parse_property_declaration (parent, attrs);
return;
default:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]