mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-30 21:21:10 +00:00 
			
		
		
		
	 877802e252
			
		
	
	
		877802e252
		
			
		
	
	
	
	
		
			
			If the type of a variable is a built-in Variant type, then it will automatically be assigned a default value based on the type. This means that the explicit initialization may be unnecessary. Thus this commit removes the warning in such case. This also changes the meaning of the unassigned warning to happen when the variable is used before being assigned, not when it has zero assignments.
		
			
				
	
	
		
			11 lines
		
	
	
	
		
			269 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
			
		
		
	
	
			11 lines
		
	
	
	
		
			269 B
		
	
	
	
		
			GDScript
		
	
	
	
	
	
| func test():
 | |
| 	var unassigned
 | |
| 	print(unassigned)
 | |
| 	unassigned = "something" # Assigned only after use.
 | |
| 
 | |
| 	var a
 | |
| 	print(a) # Unassigned, warn.
 | |
| 	if a: # Still unassigned, warn.
 | |
| 		a = 1
 | |
| 		print(a) # Assigned (dead code), don't warn.
 | |
| 	print(a) # "Maybe" assigned, don't warn.
 |