-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[Wildcard Variables] UNUSED_LOCAL_VARIABLE
support
#55719
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
Comments
UNUSED_LOCAL_VARIABLE
reporting to flag multiple _
sUNUSED_LOCAL_VARIABLE
reporting to flag multiple _
s
UNUSED_LOCAL_VARIABLE
reporting to flag multiple _
sUNUSED_LOCAL_VARIABLE
support
Follow-up from #57132, Proposal: report
|
This resurfaced while testing const evaluation in the analyzer, in a comment here. We should probably remove the
EDIT: WAI; see below. |
Revisiting this case, I think it's actually working as intended and we're getting tripped up by the test framework. Here's the test: test_visitSimpleIdentifier_wildcard_local() async {
await assertErrorsInCode(r'''
test() {
const _ = true;
const c = _;
}
''', [
error(WarningCode.UNUSED_LOCAL_VARIABLE, 35, 1),
error(CompileTimeErrorCode.UNDEFINED_IDENTIFIER, 39, 1),
error(CompileTimeErrorCode.CONST_INITIALIZED_WITH_NON_CONSTANT_VALUE, 39,
1),
]);
} The unused variable being reported is actually Offset-based tests test expectations are easy to get tripped up by! @kallentu: do you recall the intention of the test? If it's valuable as-is, we could make it a little more explicit by updating the expectation like so: error(WarningCode.UNUSED_LOCAL_VARIABLE, 35, 1, messageContains: ["'c'"]), |
Ah, that makes a lot more sense. Woops, sorry for the noise. The test was mainly trying to make sure we would produce an error if we tried to access/use the |
See: #55719 Change-Id: I4e7bea8c571f3c52313a6f69af3837982a829207 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382441 Reviewed-by: Kallen Tu <kallentu@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
As per the discussion in #59470, we want to start reporting
UNUSED_LOCAL_VARIABLE
for non wildcard underscore cases (e.g.,__
,___
, etc).UPDATE: non-wildcard underscores will produce diagnostics but whether we want to start reporting on other identifiers (e.g.,
e
orexception
) is still an open question. (See proposal below.)The text was updated successfully, but these errors were encountered: