Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type compatibility error in loop #48988

Closed
SaracenOne opened this issue May 23, 2021 · 3 comments
Closed

Type compatibility error in loop #48988

SaracenOne opened this issue May 23, 2021 · 3 comments

Comments

@SaracenOne
Copy link
Member

Godot version:
45d3b96

OS/device including version:
Windows 10

Issue description:
The error 'Parser bug (please report): Trying to check compatibility of unset value type' is printed when passing an i variable of a loop into the float function.

Steps to reproduce:
Launch attached project

Minimal reproduction project:
type_compatibility.zip

@nonunknown
Copy link
Contributor

nonunknown commented May 28, 2021

All these are related to these one: #45139 & #44375

I can confirm it when typing this on my script:

func project_ray() -> void:
	var cam:Camera3D = $Gizmo/Camera3D
	var from = cam.project_ray_origin(mouse_pos)
	var to = from + cam.project_ray_normal(mouse_pos) * 1000
	var result = get_world_3d().direct_space_state.intersect_ray(from
	,to, [self])

@Blackiris
Copy link
Contributor

Blackiris commented Jun 17, 2021

In the reproduction project, the i variable kind is still unresolved when analyzing the call.

The i variable type should in fact be guessed from the for i in rang(0,1): expression but it is currently not yet the case.
In GDScriptAnalyzer::resolve_for, there is even a TODO comment about this:

	// TODO: If list is a typed array, the variable should be an element.
	// Also applicable for constant range() (so variable is int or float).

[EDIT]
By replacing this comment by:

	GDScriptParser::DataType var_type = p_for->variable->get_datatype();
	var_type.kind = GDScriptParser::DataType::VARIANT;
	p_for->variable->set_datatype(var_type);

The error message disappears, but to be honest, I don't have any idea what datatype means...

@cdemirer
Copy link
Contributor

cdemirer commented Jul 6, 2022

Can't reproduce on current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants