I'm usually happy with GDScript's type checking, but this case doesn't work and surprised me

Godot Version

4.3

Question

I have these lines in one of my scripts. I would have expected Godot to mark this as an error (or warning) because I’m accessing an attribute that doesn’t exist on a known type, but it doesn’t.

		var query := PhysicsPointQueryParameters2D.new()
		query.this_attribute_doesnt_exist = 'not ideal'

Godot will not identify anything wrong with those 2 lines.

Is there something wrong with my setup? Does anyone else get an error or warning if you put those 2 lines in your script?

Try enabling debug/gdscript/warnings/unsafe_property_access

2 Likes

That fixes it, thanks.

I’ll have to remember that these settings are per project and not global.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.