mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
GDScript: Add static typing for for loop variable
This commit is contained in:
parent
0511f9d9a7
commit
6c59ed9485
20 changed files with 177 additions and 17 deletions
|
|
@ -1850,7 +1850,18 @@ GDScriptParser::ForNode *GDScriptParser::parse_for() {
|
|||
n_for->variable = parse_identifier();
|
||||
}
|
||||
|
||||
consume(GDScriptTokenizer::Token::IN, R"(Expected "in" after "for" variable name.)");
|
||||
if (match(GDScriptTokenizer::Token::COLON)) {
|
||||
n_for->datatype_specifier = parse_type();
|
||||
if (n_for->datatype_specifier == nullptr) {
|
||||
push_error(R"(Expected type specifier after ":".)");
|
||||
}
|
||||
}
|
||||
|
||||
if (n_for->datatype_specifier == nullptr) {
|
||||
consume(GDScriptTokenizer::Token::IN, R"(Expected "in" or ":" after "for" variable name.)");
|
||||
} else {
|
||||
consume(GDScriptTokenizer::Token::IN, R"(Expected "in" after "for" variable type specifier.)");
|
||||
}
|
||||
|
||||
n_for->list = parse_expression(false);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue