Skip to content

[Wildcard Variables] CFE Implementation #55655

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

Closed
6 of 7 tasks
Tracked by #55673
kallentu opened this issue May 6, 2024 · 1 comment
Closed
6 of 7 tasks
Tracked by #55673

[Wildcard Variables] CFE Implementation #55655

kallentu opened this issue May 6, 2024 · 1 comment
Assignees
Labels
feature-wildcard-variables Implementation of the wildcard variables feature legacy-area-front-end Legacy: Use area-dart-model instead. model-features General feature work in the analyzer and CFE.

Comments

@kallentu
Copy link
Member

kallentu commented May 6, 2024

Issue may be edited as we add more items of work.

A general outline of areas that need to be updated for the wildcards feature:

  • Decide how we would like to represent _ in the CFE (body_builder)
  • Update function signatures allowing multiple _s (outline_builder)
  • Update the scope look up to avoid finding local declarations of _. May come naturally if we don't register _ as valid in-scope elements. (body_builder)
  • Update error handling.
  • Suppress unused variable warnings for _ local declarations.
  • Add unit tests and CFE file tests.
  • Lower unique variable names to the backends.

cc. @chloestefantsova @johnniwinther @stereotype441

@kallentu kallentu added legacy-area-front-end Legacy: Use area-dart-model instead. model-features General feature work in the analyzer and CFE. feature-wildcard-variables Implementation of the wildcard variables feature labels May 6, 2024
@kallentu kallentu changed the title [Wildcards] CFE Implementation [Wildcard Variables] CFE Implementation May 7, 2024
@kallentu kallentu self-assigned this May 7, 2024
copybara-service bot pushed a commit that referenced this issue Jun 6, 2024
Local variables named `_` are no longer in scope and can't be used when the wildcard variables experiment is enabled.

Bug: #55655
Change-Id: I13a7a9fcfb92e4b64bd51b5ccfe657f5a0633233
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369507
Reviewed-by: Chloe Stefantsova <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 10, 2024
Adds the `isWildcard` flag to variables. Will be using this for producing better errors.

TEST= Existing expectations tests for wildcards pass with new flag.
Bug: #55655
Change-Id: If2f7a5555e7cc26e84d1b1e63e4261c81a157d78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370062
Reviewed-by: Alexander Markov <[email protected]>
Reviewed-by: Chloe Stefantsova <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 12, 2024
Only set `isWildcard` on variables when the experiment for wildcards is enabled.

Bug: #55655
Change-Id: I54a1f0ba1b9192df6c86e44e92d5ff4bebc9a232
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371020
Commit-Queue: Kallen Tu <[email protected]>
Reviewed-by: Chloe Stefantsova <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 12, 2024
This CL changes the following:
- Formal parameter wildcards can have duplicate declarations.
- Formal parameter wildcards will produce an error when used.

Most of this CL is still needed even if we want to keep these parameters in scope. I'm working on that so I'll put this out in the meantime. The tech debt is small compared to getting a move forward on the functionality of wildcards.

Bug: #55655
Change-Id: I5a8b6a8081ea6deb4cfd4bf2626280c6e8c98989
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370761
Reviewed-by: Chloe Stefantsova <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 14, 2024
…alue.

Wildcard optional parameters aren't used anyways, so it doesn't matter if they have a default value.
This CL removes the error that's typically there.

Bug: #55655
Change-Id: Ie7286e1c3650fa347b1c28f1cc4ebd657cca33de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371560
Commit-Queue: Kallen Tu <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 14, 2024
Positional record type fields named `_` are wildcards. They are non-binding and will not collide with other wildcard fields.

Bug: #55655
Change-Id: Ic6985da5bdb32564402d084a3282fa448ff28cbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371040
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 14, 2024
Local functions named `_` are treated the same as local wildcard variables.
They cannot be referred to.
This CL changes that behaviour.

Bug: #55655
Change-Id: Idbbe2a4f5b406d4499602e808f6541af6451fb31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371480
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 17, 2024
Change main() to test() so we don't need an entry in the status file.

Bug: #55655
Change-Id: I41e6a70ce486279389e4d613f52e9ceb62c8e792
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371783
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 18, 2024
This CL prevents function wildcard parameter collisions and avoids adding function wildcard parameters to scope.

Bug: #55655
Change-Id: I5a8b85ceef15b355f6a36a1d1d19df038980331d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371941
Reviewed-by: Johnni Winther <[email protected]>
Reviewed-by: Chloe Stefantsova <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 20, 2024
Wildcard type parameters are not added to the scope of the class. They do not collide with other wildcards or other wildcard type parameters.

Bug: #55655
Change-Id: I473a5023c570623fe2a11df5c07d491082bab642
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371943
Commit-Queue: Kallen Tu <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
Reviewed-by: Chloe Stefantsova <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 21, 2024
…inding.

This CL adds `isWildcard` to `StructuralVariableBuilder` and allows type variables in functions and function types. It also removes them from scope so they can't be used.

Bug: #55655
Change-Id: I26237375480318dd0c9a01cb59b3426b783ca7be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372240
Reviewed-by: Johnni Winther <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
Reviewed-by: Chloe Stefantsova <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 24, 2024
Bug: #55655
Change-Id: I938c254fad2c656c9342e9cea5b146373b9f63e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372603
Commit-Queue: Kallen Tu <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jun 24, 2024
No initializer list variable is created with this._ and super._ initializing formals.

this._ will still initialize fields and super._ will forward the argument's value to the super constructor invocation.

Bug: #55655
Change-Id: Id4cb25d0ecaf3518cc577e37b74a349d19418679
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372600
Commit-Queue: Kallen Tu <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jul 2, 2024
This CL converts VariableDeclarations to ExpressionStatements or EmptyStatements.
If the declaration has an initializer, it will be converted to an ExpressionStatement, otherwise, an EmptyStatement.

This will help the VM and potentially other backends, avoid allocating space for a variable declaration that will never be used.

Bug: #55655
Change-Id: I845b7e5e61fbb0340623ec0dee7269491bc09513
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/373640
Commit-Queue: Kallen Tu <[email protected]>
Reviewed-by: Chloe Stefantsova <[email protected]>
copybara-service bot pushed a commit that referenced this issue Jul 31, 2024
…d parameters.

Follow up to https://dart-review.googlesource.com/c/sdk/+/373621. Cleaning up the name changing and checking for extension types.

Bug: #55655
Change-Id: I373d4d12467cbed0d79effd2f81c16284119256a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/378021
Reviewed-by: Chloe Stefantsova <[email protected]>
Commit-Queue: Kallen Tu <[email protected]>
@kallentu
Copy link
Member Author

CFE Implementation is now complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-wildcard-variables Implementation of the wildcard variables feature legacy-area-front-end Legacy: Use area-dart-model instead. model-features General feature work in the analyzer and CFE.
Projects
None yet
Development

No branches or pull requests

1 participant