Skip to content

dart --enable-experiment=constructor-tearoffs format doesn't #46718

@eernstg

Description

@eernstg

The following program causes dart format (from ef8add0) to request the experiment which is actually enabled:

X id<X>(X x) => x;
void main() => id<int>;

Here is the response from dart --enable-experiment=constructor-tearoffs format n035.dart where n035.dart is the name of the file storing the above library:

> head_test_dart --enable-experiment=constructor-tearoffs format n035.dart
Could not format because the source could not be parsed:

line 2, column 18 of n035.dart: This requires the 'constructor-tearoffs' language feature to be enabled.
  ╷
2 │ void main() => id<int>;
  │                  ^^^^^
  ╵
Formatted no files in 0.13 seconds.

It makes sense that this feature may not yet be implemented, but it is surprising that it causes the requires .. enabled message to be emitted.

Trying out other experiments (including some strings that aren't the name of any experiment), it seems likely that the --enable-experiment=... is ignored completely. Is that intended? (It could be intended that the formatter only supports one language version, but it would then still be helpful to handle the --enable-experiment option explicitly).

Metadata

Metadata

Assignees

Labels

area-dart-cliUse area-dart-cli for issues related to the 'dart' command like tool.dart-cli-formatIssues related to the 'dart format' tool

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions