Skip to content

[Records] Constant evaluation errors inside record literals #50132

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
alexmarkov opened this issue Oct 5, 2022 · 0 comments
Closed

[Records] Constant evaluation errors inside record literals #50132

alexmarkov opened this issue Oct 5, 2022 · 0 comments
Assignees
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.

Comments

@alexmarkov
Copy link
Contributor

Part of #49713.

Test co19/LanguageFeatures/Records/canonicalization_A02_t01 fails because front-end doesn't treat const constructor parameters as potentially constant if they are used inside record literal:

class A {
  final (int, int) pair;
  const A(int x, int y) : pair = (x, y);
}

void main() {
  print(const A(1, 2));
}
foo.dart:3:34: Error: Constant evaluation error:
  const A(int x, int y) : pair = (x, y);
                                 ^
foo.dart:3:35: Context: The variable 'x' is not a constant, only constant expressions are allowed.
  const A(int x, int y) : pair = (x, y);
                                  ^

@johnniwinther

@alexmarkov alexmarkov added the legacy-area-front-end Legacy: Use area-dart-model instead. label Oct 5, 2022
@johnniwinther johnniwinther self-assigned this Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-front-end Legacy: Use area-dart-model instead.
Projects
None yet
Development

No branches or pull requests

2 participants