dart-lang / dart-lang/language
Allow `with` as function name
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Flutter has a class that has multiple factory methods which start with "with". I'd like to make one named "with" that supersedes them. By keeping the names the same they will show up together in intellesense. I'm unable to name a constructor "with" because it's a reserved keyword.
By context we should be able to allow this name.
## example
```dart
class Foo {
Foo withBar(int bar) => ...;
Foo withBaz(int baz) => ...;
// Unable to add this function.
Foo with({int? bar, int? baz}) => ...;
}
```
## generated error
```
Error: 'with' can't be used as an identifier because it's a keyword.
```
Contributor guide
Research direction
Start by reviewing the issue's `Foo` constructor example and the generated reserved-keyword error. Trace the Dart language rules for identifiers, keywords, and named constructors, then determine what specification and implementation areas would need to change. Done means `with` is accepted in this context without weakening its other keyword uses, with coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100