Skip to content
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

Static access shorthand parsing question #4218

Open
sgrekhov opened this issue Dec 30, 2024 · 1 comment
Open

Static access shorthand parsing question #4218

sgrekhov opened this issue Dec 30, 2024 · 1 comment
Labels
bug There is a mistake in the language specification or in an active document

Comments

@sgrekhov
Copy link
Contributor

With the Static access shorthand feature how should the following be parsed?

enum E {
  e1, e2;
  static E? one = null;
}

main() {
  var l1 = <E>[
    ....values // Error?
  ];
  var l2 = <E>[
    ... .values // ... E.values?
  ];
  var l3 = <E>[
    ...?.values // Error?
  ];
  var l4 = <E>[
    ...? .values // ...? E.values?
  ];

  var l5 = <E>[
    ?.one // Null-aware element `?E.one`?
  ];
@sgrekhov sgrekhov added the bug There is a mistake in the language specification or in an active document label Dec 30, 2024
@lrhn
Copy link
Member

lrhn commented Dec 30, 2024

As I understand the lexical rules, tokenization is always "as far as possible".

  • ....values should tokenize as ... . values which can be valid, but likely won't be unless values is a static on Iterable or Map, since that's the context type of a spread.

  • ... .values. Same, and context type is Iterable<E>.

  • ...?.values and ...? .values tokenize the same, context type Iterable<E>?.

  • ?.one should tokenize ?. as one token which isn't valid in that position. You need ? .one for that to work. That is likely going to be an issue, I expect null-aware elements to format without a space otherwise (@munificent).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug There is a mistake in the language specification or in an active document
Projects
None yet
Development

No branches or pull requests

2 participants