diff options
author | Bojidar Marinov <bojidar.marinov.bg@gmail.com> | 2019-12-02 22:21:49 +0200 |
---|---|---|
committer | Bojidar Marinov <bojidar.marinov.bg@gmail.com> | 2019-12-02 22:26:05 +0200 |
commit | 79c26344e8ce3eee63783498c50ed46a81ed123e (patch) | |
tree | 61a5db081c931ceb235c9463ead945dbfe2f7eca | |
parent | 0e54b2d43c8d48b97fc3300dea679a05efa28dca (diff) |
Make error when accidentially redeclaring a variable's type clearer
Fixes #32370
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 74b9440b3a..a4fe5be3e8 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; } |