I noticed this when accidentally running formatted code through the formatter.
Given this code (taken from the SDK):
extension type JSExportedDartFunction._(
JSExportedDartFunctionRepType _jsExportedDartFunction
) implements JSFunction {}
The tall formatter produces this:
extension type JSExportedDartFunction._(
JSExportedDartFunctionRepType _jsExportedDartFunction,
) implements JSFunction {}
If you try to format this code again, it fails with:
Could not format because the source could not be parsed:
line 2, column 56 of .: The representation field can't have a trailing comma.
Here's a repro that formats the code twice with/without tall mode. Only the very last line (re-formatting after already formatting with tall mode) fails:
Future<void> test_newlines() async {
var formatter = dart_style.DartFormatter();
var tallFormatter = dart_style.DartFormatter(
experimentFlags: [
'tall-style',
],
);
var code = r'''
extension type JSExportedDartFunction._(
JSExportedDartFunctionRepType _jsExportedDartFunction
) implements JSFunction {}
''';
print(jsonEncode(code));
print(jsonEncode(formatter.format(code)));
print(jsonEncode(formatter.format(formatter.format(code))));
print(jsonEncode(tallFormatter.format(code)));
print(jsonEncode(tallFormatter.format(tallFormatter.format(code))));
}
I noticed this when accidentally running formatted code through the formatter.
Given this code (taken from the SDK):
The tall formatter produces this:
If you try to format this code again, it fails with:
Here's a repro that formats the code twice with/without tall mode. Only the very last line (re-formatting after already formatting with tall mode) fails: