Skip to content

Analyzer barfs parsing .. spreads? I'm not sure, included a minimal repro. #63

@matanlurey

Description

@matanlurey
% dart --version
Dart SDK version: 3.3.1 (stable) (Wed Mar 6 13:09:19 2024 +0000) on "macos_arm64"

The following code does successfully execute, and gets highlighting, but depending on the tool (VSCode, Dartpad, etc) the syntax highlighting is off.

void main() {
  final code = StringBuffer();
  final data = null as dynamic;
  code.writeln(
    'final cards = <CardOrVariant>${_createList([
          ...data.cards.map(
            (c) => _invokeConstructor(
              'CanonicalCard',
              {
                'card': _nameToIdentifier(c.title),
              },
              indent: '  ',
            ),
          ),
          ..._collectVariants(data.cards, count: data.count),
        ])};',
  );
}

String _createList(
  Iterable<String> elements,
) {
  throw UnimplementedError();
}

String _nameToIdentifier(String name) {
  throw UnimplementedError();
}

String _invokeConstructor(
  String name,
  Map<String, String> fields, {
  String indent = '',   
}) {
  throw UnimplementedError();
}

Iterable<String> _collectVariants(
  Iterable<Never> cards, {
  required int count,
}) {
  throw UnimplementedError();
}

Example in VSCode, the trailing ])};', all look like they are in a string, but they are within ${...} blocks.

image

Dartpad looks worse (even more of the expression is highlighted as a string):

Screenshot 2024-03-20 at 5 11 12 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions