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

Add STATIC_CALLED_ON_INSTANCE warning #67365

Merged
merged 1 commit into from
Oct 15, 2022

Conversation

clayjohn
Copy link
Member

@akien and I discussed this in the PR review meeting this morning. This warns users when they call static functions from objects instead of calling them from the class.

The purpose of this warning is to avoid the silent failure resulting from functions which have become static recently (e.g. #67319).

Now users will have a warning hinting that they may need to change their code.

The following code:

func _ready():
	var img = Image.new()
	img.create(4, 4, false, Image.FORMAT_RGBA8)
	var imgtex = ImageTexture.new()
	imgtex.create_from_image(img)

Results in this warning
Screenshot from 2022-10-13 12-43-45

Once this PR and #67361 are merged, we should be able to move forward with making some other functions static as in #63332

@clayjohn clayjohn added this to the 4.0 milestone Oct 13, 2022
@clayjohn clayjohn requested a review from a team as a code owner October 13, 2022 19:50
@clayjohn clayjohn requested a review from a team as a code owner October 13, 2022 21:09
modules/gdscript/gdscript_warning.cpp Outdated Show resolved Hide resolved
modules/gdscript/gdscript_analyzer.cpp Show resolved Hide resolved
modules/gdscript/gdscript_warning.cpp Outdated Show resolved Hide resolved
modules/gdscript/gdscript_warning.h Outdated Show resolved Hide resolved
when static functions are called directly from objects
@akien-mga akien-mga merged commit f546d70 into godotengine:master Oct 15, 2022
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants