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

[Wildcard Variables] DDC Implementation #55751

Open
Tracked by #55673
kallentu opened this issue May 16, 2024 · 5 comments
Open
Tracked by #55673

[Wildcard Variables] DDC Implementation #55751

kallentu opened this issue May 16, 2024 · 5 comments
Assignees
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. feature-wildcard-variables Implementation of the wildcard variables feature web-dev-compiler

Comments

@kallentu
Copy link
Member

kallentu commented May 16, 2024

This issue tracks the work needed for the wildcard variables feature to be supported in DDC.
Spec: https://github.com/dart-lang/language/blob/main/working/wildcards/feature-specification.md

We may need to do some additional work to support multiple wildcard parameters in functions.

class A {
  int add(int a, int b) => 3;
}

class C implements A {
  int add(int _, int _) => 3;
}

cc. @sigmundch Feel free to tag or reassign as you see fit.
I'd also appreciate more details so we don't lose that context.

@kallentu kallentu added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label May 16, 2024
@sigmundch
Copy link
Member

Thanks @kallentu

  • the work here depends a lot on what kind of lowering we end up doing in the CFE
  • the lowering will likely convert the wildcard variables into something, potentially a variable declaration that is never read.
  • if the lowering uses the existing representation of variable declarations and guarantees uniqueness of variable names like today parameters have, then the backend may not need to do anything special for it to generate valid JavaScript. However, if the variable is represented by a new kernel node or a node that breaks current invariants, we may need some relatively small amount of work to emit valid JavaScript function declarations. The work could be similar to what DDC already does for temporary variables in Let expressions.
  • Aside from implementing the feature, the debugger support may not need much work either. We need however to have consistent semantics in expression evaluation. If in the body of the method an expression to be evaluated uses _, we need to decide if it is rejected and, if not, what to generate in that case.

@nshahan
Copy link
Contributor

nshahan commented May 16, 2024

Depending on how the CFE lowers the wildcards, and how we want them to appear (or not appear) in the debugger there could likely be some collaboration needed between DDC and DWDS to get it working.
cc @bkonyi

@kallentu
Copy link
Member Author

If there's work for web debugging, I've created an issue to track that: #55752

@bkonyi
Copy link
Contributor

bkonyi commented May 16, 2024

I was under the assumption that the spec specified that wildcard variables won't be bound to a variable and that there will be no way to reference them. Is that not the case? Regardless, I don't think we want them to appear in the debugger, especially since we can have multiple wildcard variables in the same scope.

@sigmundch
Copy link
Member

Correct - I think the nuance here is that in the code we emit in JavaScript we need to introduce a placeholder name to generate a valid function signature.

While our intent was to eventually make dwds model all of its state based on what we know from the dart program, there were cases in the past where it created its internal model based on the Chrome debugger's state of the application. If that is still the case today, we may need to do some work to ensure those synthetic variables are properly ignored/hidden.

@kallentu kallentu added the feature-wildcard-variables Implementation of the wildcard variables feature label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. feature-wildcard-variables Implementation of the wildcard variables feature web-dev-compiler
Projects
None yet
Development

No branches or pull requests

4 participants