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

Different behavior of CFE and the analyzer when constant depends on itself #59945

Open
sgrekhov opened this issue Jan 21, 2025 · 2 comments
Open
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-front-end Use area-front-end for front end / CFE / kernel format related issues. P2 A bug or feature request we're likely to work on type-question A question about expected behavior or functionality

Comments

@sgrekhov
Copy link
Contributor

The following code produces an error in the analyzer but no issues in VM.

const int? one = 2 > 1 ? null : one; // Analyzer error: The compile-time constant expression depends on itself

main() {
  print(one); // prints null
}

If to change the example to really invoke the constant then VM produces an error as well.

const int? two = 2 > 1 ? two: null; // Error: Constant evaluation error. Context: Constant expression depends on itself.

main() {
  print(two);
}

@eernstg @lrhn does in the first case the constant really depends on itself?

@sgrekhov sgrekhov added the type-question A question about expected behavior or functionality label Jan 21, 2025
@dart-github-bot
Copy link
Collaborator

Summary: Analyzer detects self-referential constant one, but the VM doesn't, though a modified example (two) triggers VM error. Inconsistency needs investigation.

@dart-github-bot dart-github-bot added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Jan 21, 2025
@sgrekhov sgrekhov changed the title Differenf bahavior of VM and the analyzer when constant depends on itself Different behavior of VM and the analyzer when constant depends on itself Jan 21, 2025
@mraleph mraleph changed the title Different behavior of VM and the analyzer when constant depends on itself Different behavior of CFE and the analyzer when constant depends on itself Jan 21, 2025
@mraleph mraleph added area-front-end Use area-front-end for front end / CFE / kernel format related issues. and removed area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Jan 21, 2025
@mraleph
Copy link
Member

mraleph commented Jan 21, 2025

cc @eernstg

@bwilkerson bwilkerson added the P2 A bug or feature request we're likely to work on label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. area-front-end Use area-front-end for front end / CFE / kernel format related issues. P2 A bug or feature request we're likely to work on type-question A question about expected behavior or functionality
Projects
None yet
Development

No branches or pull requests

4 participants