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

Evaluation failing for non-null, nullable field #51690

Open
kenzieschmoll opened this issue Mar 1, 2023 · 1 comment
Open

Evaluation failing for non-null, nullable field #51690

kenzieschmoll opened this issue Mar 1, 2023 · 1 comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. front-end-server Issues with the frontend server P3 A lower priority bug or feature request web-dev-compiler web-eval evaluation support on the web

Comments

@kenzieschmoll
Copy link
Contributor

a is a nullable list. At the point of evaluation, a has been checked non null.

Screenshot 2023-03-01 at 11 05 38 AM

Screenshot 2023-03-01 at 10 46 31 AM

We should either

  1. have evaluation respect the type promotion that occurs earlier in the method, or
  2. have evaluation insert a ! for nullable variable a when evaluating a.length. If a is null, I would expect a null assertion error. If a is non-null, a.length should evaluate as expected (which is the current result of a?.length)

@annagrin

@annagrin annagrin self-assigned this Mar 9, 2023
@annagrin
Copy link
Contributor

annagrin commented Mar 9, 2023

a.length is compiled by the incremental compiler, wrapped in a synthetic function, an all the scope (such as a) is passed to it as parameters.

We can investigate some solutions here:

  • compile the expression in some relaxed way (or assume any access has a !) so it fails at runtime if needed.
  • make the incremental compiler collect the type promotion information from the scope and use it in the expression compilation.

/cc @jensjoha @johnniwinther do you think any of those are feasible in the incremental compiler? For the first one, it there a setting I can pass to the incremental compiler (to ignore null safety information but not fail on null-safe syntax either?)

Transferring this to the SDK repo as the changes would need to be done in the frontend server, ddc, and maybe in the incremental compiler.

@annagrin annagrin transferred this issue from dart-lang/webdev Mar 9, 2023
@annagrin annagrin added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Mar 9, 2023
@annagrin annagrin removed their assignment Mar 9, 2023
@annagrin annagrin added front-end-server Issues with the frontend server web-eval evaluation support on the web area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. web-dev-compiler P3 A lower priority bug or feature request labels Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. front-end-server Issues with the frontend server P3 A lower priority bug or feature request web-dev-compiler web-eval evaluation support on the web
Projects
None yet
Development

No branches or pull requests

2 participants