Skip to content

dart fix for avoid_redundant_argument_values makes semantic changes when involving kIsWeb #47404

Closed
@Hixie

Description

@Hixie

dart fix for avoid_redundant_argument_values makes semantic changes when involving kIsWeb.

STEPS TO REPRODUCE

  • dart create dart_fix_test
  • Replace the dart_fix_test/bin/dart_fix_test.dart file as follows:
void test({ bool foo = true }) { }

const bool kIsWeb = identical(0, 0.0);

void main(List<String> arguments) {
  test(foo: kIsWeb);
}
  • Replace the analysis_options.yaml file as follows:
linter:
  rules:
    - avoid_redundant_argument_values
  • Run dart fix --apply

EXPECTED RESULTS

The analyzer and dart fix should magically know that identical(0, 0.0) is not a constant value despite it being a constant according to the language, and thus make no change to the code above.

ACTUAL RESULTS

The argument is removed, because kIsWeb is assumed to be true (which is weird in itself, but that's another story) and so the argument is removed. This is, of course, a significant semantic change.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions