GDScript: Show specific error when "yield" is used
To help people porting code, it gives a hint to use "await" instead of a generic error.
This commit is contained in:
parent
db028ac700
commit
262d6c6bef
|
@ -2810,6 +2810,11 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_lambda(ExpressionNode *p_p
|
|||
return lambda;
|
||||
}
|
||||
|
||||
GDScriptParser::ExpressionNode *GDScriptParser::parse_yield(ExpressionNode *p_previous_operand, bool p_can_assign) {
|
||||
push_error(R"("yield" was removed in Godot 4.0. Use "await" instead.)");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GDScriptParser::ExpressionNode *GDScriptParser::parse_invalid_token(ExpressionNode *p_previous_operand, bool p_can_assign) {
|
||||
// Just for better error messages.
|
||||
GDScriptTokenizer::Token::Type invalid = previous.type;
|
||||
|
@ -3166,7 +3171,7 @@ GDScriptParser::ParseRule *GDScriptParser::get_rule(GDScriptTokenizer::Token::Ty
|
|||
{ nullptr, nullptr, PREC_NONE }, // TRAIT,
|
||||
{ nullptr, nullptr, PREC_NONE }, // VAR,
|
||||
{ nullptr, nullptr, PREC_NONE }, // VOID,
|
||||
{ nullptr, nullptr, PREC_NONE }, // YIELD,
|
||||
{ &GDScriptParser::parse_yield, nullptr, PREC_NONE }, // YIELD,
|
||||
// Punctuation
|
||||
{ &GDScriptParser::parse_array, &GDScriptParser::parse_subscript, PREC_SUBSCRIPT }, // BRACKET_OPEN,
|
||||
{ nullptr, nullptr, PREC_NONE }, // BRACKET_CLOSE,
|
||||
|
|
|
@ -1388,6 +1388,7 @@ private:
|
|||
ExpressionNode *parse_attribute(ExpressionNode *p_previous_operand, bool p_can_assign);
|
||||
ExpressionNode *parse_subscript(ExpressionNode *p_previous_operand, bool p_can_assign);
|
||||
ExpressionNode *parse_lambda(ExpressionNode *p_previous_operand, bool p_can_assign);
|
||||
ExpressionNode *parse_yield(ExpressionNode *p_previous_operand, bool p_can_assign);
|
||||
ExpressionNode *parse_invalid_token(ExpressionNode *p_previous_operand, bool p_can_assign);
|
||||
TypeNode *parse_type(bool p_allow_void = false);
|
||||
#ifdef TOOLS_ENABLED
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#GDTEST_PARSER_ERROR
|
||||
|
||||
signal event
|
||||
|
||||
func test():
|
||||
yield("event")
|
|
@ -0,0 +1,2 @@
|
|||
GDTEST_PARSER_ERROR
|
||||
"yield" was removed in Godot 4.0. Use "await" instead.
|
Loading…
Reference in New Issue