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

[Shaders] Disallow trailing commas in function declarations #87075

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AThousandShips
Copy link
Member

Might not be the most elegant fix, but not very familiar with this code, if someone has a cleaner idea for doing this I'd appreciate suggestions. Added it with deprecation to avoid breaking existing shaders, though I'm not sure that's necessary

I was considering enclosing the whole while loop in a block to check closing paren at the start, which would make catching this easier, but want to avoid noise in the blame if I can, having to indent the whole thing.

For reasoning, see the discussion in:

Alternative to:

@AThousandShips AThousandShips added bug topic:shaders cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Jan 11, 2024
@AThousandShips AThousandShips added this to the 4.3 milestone Jan 11, 2024
@AThousandShips AThousandShips requested a review from a team as a code owner January 11, 2024 14:29
#ifdef DISABLE_DEPRECATED
// Disallow trailing comma.
if (tk.type == TK_PARENTHESIS_CLOSE) {
_set_error(RTR("Expected a valid data type for argument."));
Copy link
Member Author

Choose a reason for hiding this comment

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

Picked this error as it matches what happens if you do void foo(,)

Copy link
Contributor

Choose a reason for hiding this comment

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

Would a more user-friendly error be better, though? E.g. "(Remove the trailing comma?)"

Copy link
Member Author

Choose a reason for hiding this comment

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

Could add 🙂 considering a warning as well so working on the wording, thank you!

@AThousandShips AThousandShips removed cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release labels Jan 11, 2024
@AThousandShips
Copy link
Member Author

AThousandShips commented Jan 11, 2024

Could add a warning on non-disabled cases (i.e. default builds) if desired

Tested and it doesn't look good and isn't noticeable, also feels like a bad idea to add a new warning category just for this to allow it to be configured well

@AThousandShips AThousandShips changed the title [Shader] Disallow trailing commas in function declarations [Shaderd] Disallow trailing commas in function declarations Jan 11, 2024
@AThousandShips AThousandShips changed the title [Shaderd] Disallow trailing commas in function declarations [Shaders] Disallow trailing commas in function declarations Jan 11, 2024
@AThousandShips AThousandShips modified the milestones: 4.3, 4.4 Jun 28, 2024
@AThousandShips AThousandShips requested a review from a team October 21, 2024 12:20
@AThousandShips AThousandShips force-pushed the shader_fix branch 2 times, most recently from 328a4ae to 22db465 Compare December 1, 2024 13:13
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