mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 13:41:03 +00:00 
			
		
		
		
	Merge pull request #82139 from dalexeev/gds-add-inferred-declaration-warning
GDScript: Add `INFERRED_DECLARATION` warning
This commit is contained in:
		
						commit
						9b0b441cf3
					
				
					 5 changed files with 22 additions and 5 deletions
				
			
		|  | @ -1936,9 +1936,14 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi | |||
| 	} | ||||
| 
 | ||||
| #ifdef DEBUG_ENABLED | ||||
| 	if (!has_specified_type && !p_assignable->infer_datatype && !is_constant) { | ||||
| 	if (!has_specified_type) { | ||||
| 		const bool is_parameter = p_assignable->type == GDScriptParser::Node::PARAMETER; | ||||
| 		parser->push_warning(p_assignable, GDScriptWarning::UNTYPED_DECLARATION, is_parameter ? "Parameter" : "Variable", p_assignable->identifier->name); | ||||
| 		const String declaration_type = is_constant ? "Constant" : (is_parameter ? "Parameter" : "Variable"); | ||||
| 		if (p_assignable->infer_datatype || is_constant) { | ||||
| 			parser->push_warning(p_assignable, GDScriptWarning::INFERRED_DECLARATION, declaration_type, p_assignable->identifier->name); | ||||
| 		} else { | ||||
| 			parser->push_warning(p_assignable, GDScriptWarning::UNTYPED_DECLARATION, declaration_type, p_assignable->identifier->name); | ||||
| 		} | ||||
| 	} | ||||
| #endif | ||||
| 
 | ||||
|  | @ -2152,7 +2157,9 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) { | |||
| 		} else { | ||||
| 			p_for->variable->set_datatype(variable_type); | ||||
| #ifdef DEBUG_ENABLED | ||||
| 			if (!variable_type.is_hard_type()) { | ||||
| 			if (variable_type.is_hard_type()) { | ||||
| 				parser->push_warning(p_for->variable, GDScriptWarning::INFERRED_DECLARATION, R"("for" iterator variable)", p_for->variable->name); | ||||
| 			} else { | ||||
| 				parser->push_warning(p_for->variable, GDScriptWarning::UNTYPED_DECLARATION, R"("for" iterator variable)", p_for->variable->name); | ||||
| 			} | ||||
| #endif | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Rémi Verschelde
						Rémi Verschelde