Skip to content

elements of a const List not considered const #20574

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
trinarytree opened this issue Aug 19, 2014 · 4 comments
Closed

elements of a const List not considered const #20574

trinarytree opened this issue Aug 19, 2014 · 4 comments
Labels
closed-duplicate Closed in favor of an existing report

Comments

@trinarytree
Copy link

const x = const [1, 2];
const y = x[0];

yields
"error: ... expression is not a valid compile-time constant"

looks pretty constant to me. i don't see how it's much different from
const x = 1;
const y = x + 1;
which is allowed.

Dart VM version: 1.6.0-dev.5.1 (Thu Jul 24 19:35:53 2014) on "linux_x64"

@srawlins
Copy link
Member

This looks like a duplicate of Issue #18389.

@DartBot
Copy link

DartBot commented Aug 19, 2014

This comment was originally written by @mezoni


const x = const [1, 2];

The const [1, 2] can be canonicalized at compile time.
OK.

const y = x[0];

The x[0] can NOT be canonicalized at compile time.
FAIL.

P.S.

The const in Dart means not only constant.
The const in Dart also means can be canonicalized.
How in Dart possible canonicalize the indexed array operation?

P.S.
#­1
1 == 1
Const.
Can be canonicalized.

#­2
Colors.RED == Colors.RED
Const.
Can NOT be canonicalized.

@floitschG
Copy link
Contributor

Thanks Sam.


Added Duplicate label.
Marked as being merged into #18389.

@DartBot
Copy link

DartBot commented Nov 16, 2014

This comment was originally written by @mezoni


elements of a const List not considered const

What means "elements" of something (not only elements of the "List")?
This means a value which are the result of the operator "[]".
Is this possible in Dart (const V operator [K index])?

const x = const [1, 2];
const INDEX = x[1];
const y = x[INDEX];
const z = x[666];

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

5 participants