-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Unused arguments warning but they are used #26850
Comments
I had the same issue but I realize that if you give the same value to a new variable works... static func grid_extract_area_safe_crop(x0, y0, w, h):
var gw = 0
var gh = 0
var w1 = w
var h1 = h
if x0 < 0:
w1 += x0
x0 = 0
if y0 < 0:
h1 += y0
y0 = 0
if x0 + w1 >= gw:
w1 = gw-x0
if y0 + h1 >= gh:
h1 = gh-y0
return x0 + y0 + w1 + h1 |
I'm experiencing this with the 2.5D demo project I'm making. Tested on 3.1.1 stable and latest master. |
The warning seems to be occurring when a parameter is not visibly used on right side of a |
Adding a break at godot/modules/gdscript/gdscript_parser.cpp Line 780 in 36591b1
Also, I don't know what exactly does godot/modules/gdscript/gdscript_parser.cpp Line 779 in 36591b1
|
@Anutrix |
Thanks. godot/core/packed_data_container.cpp Line 227 in c8994b5
|
@akien-mga I am sorry. It seems the changes I made in pull request #30095 weren't enough to fix the issue and instead caused another issue.
has no warning when it should give (UNASSIGNED_VARIABLE_OP_ASSIGN). |
… issue it was supposed to fix(godotengine#26850)
… issue it was supposed to fix(godotengine#26850)
This is not fixed at 13/09/2019 24e1039 |
I just saw the pull requests and I don't know how they would fix this issue. Well, the first one was reverted, so it's fine. But the second one just made it so assignment with operation mark it as an usage, which just masked the problem. Assignment is not considered an usage, even the assignment with operations ( I know that the examples here are actually using the arguments, so the issue is valid. I just want to make clear for anyone trying to fix this (before I'm able to) that assignment is not usage. To fix this we need to see why the expressions are not counting up the usage of the arguments. |
It doesn't look like anyone has given a clear definition of usage yet, so here's mine: From that definition, here are a few things to think about (some more important that others):
|
My definition of usage (that I used to implement the warning) is quite simple:
We can probably polish that up later (e.g. use in self-assignment shouldn't count), but this basic definition should be working first. Missing a unused variable is okay, misreporting a used one is not. The more complex cases we can leave to the static analyzer. |
It seems important to make sure that
It would seem we have to opposite problem in some cases. |
It fails because there is indeed no usage if testValue is passed by value(like you said).
When counting for usage, there's no distinction done by the parser between parameters of base type and that of everything else(currently). The former shouldn't be counted if assigned(or assigned with operations) but the latter should be. |
What I mean is that the editor does not list an error as it should. It prints an error for:
But it does not print an error for
|
Godot 3.1 RC1
The following function marks
w
andh
as unused:Note: this function makes no sense because I simplified it for repro.
The text was updated successfully, but these errors were encountered: