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

UnusedParameter and UnusedVariable false positives in lambda default arguments #341

Closed
ryangreenberg opened this issue Jan 29, 2021 · 0 comments · Fixed by #342
Closed

Comments

@ryangreenberg
Copy link
Contributor

This sample code:

function ex(
	int $i,
	(function(int): int) $fn = ($a) ==> {
		foo($a);
		return 5;
	},
): void {
	$fn($i);
}

function foo(int $_i): void {}

produces these errors:

Parameter is unused
  Linter: Facebook\HHAST\UnusedParameterLinter
  Location: /Users/greenberg/code/repro/unused_repro.hack:3:29
@@ -1,6 +1,6 @@
 function ex(
  int $i,
- (function(int): int) $fn = ($a) ==> {
+ (function(int): int) $fn = ($_a) ==> {
    foo($a);
    return 5;
  },

Would you like to apply this fix?
  [y]es/[n]o/yes to [a]ll/n[o] to all: Variable is unused
  Linter: Facebook\HHAST\UnusedVariableLinter
  Location: /Users/greenberg/code/repro/unused_repro.hack:4:6
  Code:
  >$a

Both are very confused about what to do with the lambda as a parameter default value. I think UnusedParameter needs to look for parameters that are children of the declaration rather than descendants.

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

Successfully merging a pull request may close this issue.

1 participant