diff options
author | George Marques <george@gmarqu.es> | 2020-08-19 11:32:48 -0300 |
---|---|---|
committer | George Marques <george@gmarqu.es> | 2020-08-19 11:32:48 -0300 |
commit | 15b16ec0cee44a16789662670d66a174b097abdb (patch) | |
tree | 66279d7f13c409426edcbecc4627d0fc0f994067 | |
parent | cd3f51c67c9eb3e71217fd4d4f668cf811fdcf25 (diff) |
GDScript: Fix signal parameters not respecting commas
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 17798f5f7b..02c80b79c1 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -986,9 +986,15 @@ GDScriptParser::SignalNode *GDScriptParser::parse_signal() { signal->identifier = parse_identifier(); if (match(GDScriptTokenizer::Token::PARENTHESIS_OPEN)) { - while (!check(GDScriptTokenizer::Token::PARENTHESIS_CLOSE) && !is_at_end()) { + do { + if (check(GDScriptTokenizer::Token::PARENTHESIS_CLOSE)) { + // Allow for trailing comma. + break; + } + ParameterNode *parameter = parse_parameter(); if (parameter == nullptr) { + push_error("Expected signal parameter name."); break; } if (parameter->default_value != nullptr) { @@ -1000,7 +1006,8 @@ GDScriptParser::SignalNode *GDScriptParser::parse_signal() { signal->parameters_indices[parameter->identifier->name] = signal->parameters.size(); signal->parameters.push_back(parameter); } - } + } while (match(GDScriptTokenizer::Token::COMMA) && !is_at_end()); + consume(GDScriptTokenizer::Token::PARENTHESIS_CLOSE, R"*(Expected closing ")" after signal parameters.)*"); } |