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

Fix some shortcomings of UnusedParameterLinter #506

Merged
merged 1 commit into from
Aug 11, 2022

Conversation

lexidor
Copy link
Contributor

@lexidor lexidor commented Aug 11, 2022

  • Variadic parameters were not checked
    function _(int ... $x): void {} now emits an error for $x.
  • Lambda parameters are now linted in unparenthesized params.
    $x ==> 0 now emits an error for $x.
    Same applies for (int ... $x) ==> 0.
  • Added explicit tests for old style variadics.
    The linter handled them fine, but there was no test for it.

Checking for unparenthesized lambda parameters required a new linter.
The UnusedParameterLinter checked against ParameterDeclaration.
$x ==> 0; does not introduce one, so a new TNode was required.

This PR may cause old HHAST_FIXME comments to break.
You will have to upgrade:
/*HHAST_FIXME[UnusedParameter]*/ ($x) ==> 0; to
/*HHAST_FIXME[UnusedLambdaParameter]*/ ($x) ==> 0;
I suspect this linter is rarely suppressed, since the autofix is easier.

 - Variadic parameters were not checked
   function _(int ... $x): void {} now emits an error for $x.
- Lambda parameters are now linted in unparenthesized params.
   $x ==> 0 now emits an error for $x.
   Same applies for (int ... $x) ==> 0.
 - Added explicit tests for old style variadics.
   The linter handled them fine, but there was no test for it.
Checking for unparenthesized lambda parameters required a new linter.
The UnusedParameterLinter checked against ParameterDeclaration.
$x ==> 0; does not introduce one, so a new TNode was required.
This PR may cause old HHAST_FIXME comments to break.
You will have to upgrade:
/*HHAST_FIXME[UnusedParameter]*/ ($x) ==> 0; to
/*HHAST_FIXME[UnusedLambdaParameter]*/ ($x) ==> 0;
I suspect this linter is rarely suppressed, since the autofix is easier.
@Atry
Copy link
Contributor

Atry commented Aug 11, 2022

Looks good to me.

@Atry Atry merged commit 0b8dee8 into hhvm:main Aug 11, 2022
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.

3 participants