summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-12-04 06:52:22 +0100
committerGitHub <noreply@github.com>2019-12-04 06:52:22 +0100
commitf326913f4d40ae3e39e2e1ea6ca1b76978150359 (patch)
tree94ec2887f4d9937960e9243852ea1aa082664fae
parent40d1486cb317a60dc0e982cbc7ff3e6645cd5280 (diff)
parent79c26344e8ce3eee63783498c50ed46a81ed123e (diff)
Merge pull request #34067 from bojidar-bg/32370-retype-message
Make error when accidentially redeclaring a variable's type clearer
-rw-r--r--modules/gdscript/gdscript_parser.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 6ef3ab67ae..ef1a282e51 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -3349,7 +3349,12 @@ void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
}
p_block->statements.push_back(expression);
if (!_end_statement()) {
- _set_error("Expected end of statement after expression.");
+ // Attempt to guess a better error message if the user "retypes" a variable
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON && tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) {
+ _set_error("Unexpected ':=', use '=' instead. Expected end of statement after expression.");
+ } else {
+ _set_error(String() + "Expected end of statement after expression, got " + tokenizer->get_token_name(tokenizer->get_token()) + " instead");
+ }
return;
}