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

Try to guess method return type even if subscript base has no value #84264

Merged
merged 1 commit into from
Jan 12, 2025

Conversation

HolonProduction
Copy link
Member

@HolonProduction HolonProduction commented Oct 31, 2023

Fixes #78003.

We want to guess the method return type not only if the base has a reduced value but also if the base has a resolved type.

The following example shows the problem:

class B:
	func to_str(b: int):
		return str(b)

var a: B

func _ready():
	a.to_str(10) # Godot does not suggest string methods in autocompletion

Since a has no value in the example, the autocompletion does not try to guess the type of to_str(10).

Note that we need to use internal classes to observe that this PR solves the problem. There are other problems preventing it to work in the context of #78003.

@Mickeon Mickeon requested review from vnen and dalexeev March 2, 2024 19:42
@dalexeev dalexeev modified the milestones: 4.3, 4.4 Jul 24, 2024
@dalexeev dalexeev added the cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release label Jul 24, 2024
@HolonProduction HolonProduction force-pushed the autocompletion-78003 branch 3 times, most recently from 91eeb90 to 69275e4 Compare September 7, 2024 12:32
@HolonProduction
Copy link
Member Author

Rebased and added a test case

Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving on principle. Doing this speeds up... a general workflow where writing code faster is a priority and polishing it with static typing is an afterthought. In other words, it's just nice.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give this a try!

@akien-mga
Copy link
Member

Might use a rebase though, there's been changes to the test suite in recent months so we should make sure it still works properly.

@HolonProduction HolonProduction requested a review from a team as a code owner January 11, 2025 21:46
@HolonProduction
Copy link
Member Author

Rebased and adjusted the test to account for #99102

Copy link
Member

@dalexeev dalexeev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't tested, but it makes sense to me.

@akien-mga akien-mga merged commit 632c77e into godotengine:master Jan 12, 2025
20 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.3 Considered for cherry-picking into a future 4.3.x release topic:editor topic:gdscript
Projects
None yet
4 participants