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

Typed variable has wrong type if assigned from untyped function #34791

Closed
KoBeWi opened this issue Jan 3, 2020 · 2 comments · Fixed by #34916
Closed

Typed variable has wrong type if assigned from untyped function #34791

KoBeWi opened this issue Jan 3, 2020 · 2 comments · Fixed by #34916
Assignees
Milestone

Comments

@KoBeWi
Copy link
Member

KoBeWi commented Jan 3, 2020

Godot version:
71d372a

Issue description:
This fails:

func test():
	return true

func _ready():
	var a: int = test()
	if a == 1:
		print("Ok?")

image

If the function is typed or you use var a: int = true, it will work. I'd expect that a typed variable is properly converted in all cases.

@bojidar-bg
Copy link
Contributor

I think resolving this might indirectly lessen the effects of #24035.

@dalexeev
Copy link
Member

dalexeev commented Jan 6, 2020

This is a duplicate of #32905.

The error occurs only when a variable is declared in a certain way:

func test():
    return true

func _ready():
    var a: int = test()
    var b := test() as int
    var c := int(test())
    prints(a is int, b is int, c is int)
    # False True True

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

Successfully merging a pull request may close this issue.

5 participants