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

Update the grammar to prevent an extension from having the name type #3431

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

eernstg
Copy link
Member

@eernstg eernstg commented Oct 25, 2023

This PR adjusts the Dart grammar such that the name of an extension declaration can not be type, without turning type into a built-in identifier. This eliminates an ambiguity where the same declaration could at the same time be an extension type declaration and an extension declaration. See #3258 for more details.

@lrhn
Copy link
Member

lrhn commented Oct 25, 2023

LGTM.

Is this a breaking change or a language versioned change?
That is, will it affect language versions prior to releasing extension types?
(I'm fine with it being breaking.)

If not breaking, it should probably not go into the spec before the rest of extension types.

@eernstg
Copy link
Member Author

eernstg commented Oct 26, 2023

It is a breaking change at this time or later, because we could have a declaration of the form extension type on (T v,) {...} which is currently an extension named type. That declaration would be a syntax error unless and until the extension type feature is enabled, and it would then surely be have some compile-time errors because the declaration would need to use this differently when it is parsed as an extension type. Also, every call-site for members declared by this extension would almost inevitably turn into compile-time errors.

Nevertheless, I cannot see any occurrences of extension type on anywhere, and it seems likely that there are no such declarations in the first place.

So it's a breaking change no matter what, and we might as well deal with it now.

@eernstg
Copy link
Member Author

eernstg commented Oct 30, 2023

OK, I initiated the breaking change process: dart-lang/sdk#53883.

@eernstg eernstg merged commit 8a4003d into main Oct 31, 2023
@eernstg eernstg deleted the specify_3258_ambiguity_oct23 branch October 31, 2023 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants