mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 21:51:22 +00:00 
			
		
		
		
	GDScript: Remove error when coroutine is called without await
In the case the call happens as a statement, since the return value isn't used in this case.
This commit is contained in:
		
							parent
							
								
									056a54db7b
								
							
						
					
					
						commit
						749d89ae38
					
				
					 2 changed files with 7 additions and 7 deletions
				
			
		|  | @ -1069,7 +1069,7 @@ void GDScriptAnalyzer::resolve_node(GDScriptParser::Node *p_node) { | |||
| 		case GDScriptParser::Node::SUBSCRIPT: | ||||
| 		case GDScriptParser::Node::TERNARY_OPERATOR: | ||||
| 		case GDScriptParser::Node::UNARY_OPERATOR: | ||||
| 			reduce_expression(static_cast<GDScriptParser::ExpressionNode *>(p_node)); | ||||
| 			reduce_expression(static_cast<GDScriptParser::ExpressionNode *>(p_node), true); | ||||
| 			break; | ||||
| 		case GDScriptParser::Node::BREAK: | ||||
| 		case GDScriptParser::Node::BREAKPOINT: | ||||
|  | @ -1658,7 +1658,7 @@ void GDScriptAnalyzer::resolve_return(GDScriptParser::ReturnNode *p_return) { | |||
| 	p_return->set_datatype(result); | ||||
| } | ||||
| 
 | ||||
| void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expression) { | ||||
| void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expression, bool p_is_root) { | ||||
| 	// This one makes some magic happen.
 | ||||
| 
 | ||||
| 	if (p_expression == nullptr) { | ||||
|  | @ -1686,7 +1686,7 @@ void GDScriptAnalyzer::reduce_expression(GDScriptParser::ExpressionNode *p_expre | |||
| 			reduce_binary_op(static_cast<GDScriptParser::BinaryOpNode *>(p_expression)); | ||||
| 			break; | ||||
| 		case GDScriptParser::Node::CALL: | ||||
| 			reduce_call(static_cast<GDScriptParser::CallNode *>(p_expression)); | ||||
| 			reduce_call(static_cast<GDScriptParser::CallNode *>(p_expression), p_is_root); | ||||
| 			break; | ||||
| 		case GDScriptParser::Node::CAST: | ||||
| 			reduce_cast(static_cast<GDScriptParser::CastNode *>(p_expression)); | ||||
|  | @ -2056,7 +2056,7 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o | |||
| 	p_binary_op->set_datatype(result); | ||||
| } | ||||
| 
 | ||||
| void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_await) { | ||||
| void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_await, bool p_is_root) { | ||||
| 	bool all_is_constant = true; | ||||
| 	Map<int, GDScriptParser::ArrayNode *> arrays; // For array literal to potentially type when passing.
 | ||||
| 	for (int i = 0; i < p_call->arguments.size(); i++) { | ||||
|  | @ -2415,7 +2415,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if (call_type.is_coroutine && !is_await) { | ||||
| 	if (call_type.is_coroutine && !p_is_await && !p_is_root) { | ||||
| 		push_error(vformat(R"*(Function "%s()" is a coroutine, so it must be called with "await".)*", p_call->function_name), p_call->callee); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 George Marques
						George Marques