dart-lang / dart-syntax-highlight

Tools and documentation for how Dart code is formatted
BSD 3-Clause "New" or "Revised" License
22 stars 11 forks source link

Should 'when' be in the list of keywords? #42

Closed devoncarew closed 1 year ago

devoncarew commented 1 year ago

I see 'when' in the list of keywords in the grammar in this repo, but I don't believe it's an actual built-in identifier or a reserved word?

https://github.com/dart-lang/dart-syntax-highlight/blob/master/grammars/dart.json#L320

Am I missing something in the spec, or is this a historical artifact of this grammar file?

cc @DanTup

DanTup commented 1 year ago

Looks like I added this in #38, as it's used in guarded patterns:

https://github.com/dart-lang/language/blob/master/accepted/future-releases/0546-patterns/feature-specification.md#switch-statement

I think we'd expect it to be coloured in this way here? This grammar here is quite loose so it may be highlighted in more places than just here, although I'd expect semantic tokens to fix those (if they don't, and we see an incorrect highlight once semantic tokens are applied, I'd consider that a semantic tokens bug).

WDYT?

devoncarew commented 1 year ago

Ah, thanks for the correction :)

...return|switch|while|when)...

It looks like I reviewed that PR as well. I'd thought perhaps that was older artifacts in the file, but it looks like it's new highlighting to support upcoming features.