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

Clarify specification of allowable symbols in constant expressions #34464

Open
eernstg opened this Issue Sep 14, 2018 · 3 comments

Comments

3 participants
@eernstg
Member

eernstg commented Sep 14, 2018

In dartLangSpec.tex section \ref{maps} we have the following sentence about constant maps:

It is a compile-time error if the key of an entry in a constant map literal is an instance of a class that implements the operator \code{==} unless the key is a
%symbol,
string, an integer, a literal symbol or the result of invoking a constant constructor of class \code{Symbol}.

We need to clarify this such that it admits arbitrary constant expressions whose value is a platform symbol (that is, its dynamic type implements Symbol and it was obtained using a symbol literal or a constant object expression of the form const? Symbol(...) or const? $p$.Symbol(...)). We have made an attempt to achieve this by talking about the value but referring to the history (that is, how was that value obtained "originally"). It should be possible to say that in a way which is more precise, without talking about "the secret subclass of Symbol that the vm uses, and the one for dart2js, etc".

@eernstg eernstg self-assigned this Sep 14, 2018

@eernstg eernstg added this to To do in Dart Language Specification via automation Sep 14, 2018

@eernstg

This comment has been minimized.

Show comment
Hide comment
@eernstg

eernstg Sep 14, 2018

Member

For example, the following must be error free:

const Symbol b = Symbol("b");
const map = {b : b};
foo(Symbol s) {
  switch (s) {
    case b: print("b!"); break;
  }
}
Member

eernstg commented Sep 14, 2018

For example, the following must be error free:

const Symbol b = Symbol("b");
const map = {b : b};
foo(Symbol s) {
  switch (s) {
    case b: print("b!"); break;
  }
}
@leafpetersen

This comment has been minimized.

Show comment
Hide comment
@leafpetersen

leafpetersen Sep 14, 2018

Member

Is this a matter of matching the spec to implementations, or is this a change that we need to roll out?

Member

leafpetersen commented Sep 14, 2018

Is this a matter of matching the spec to implementations, or is this a change that we need to roll out?

@lrhn

This comment has been minimized.

Show comment
Hide comment
@lrhn

lrhn Sep 15, 2018

Member

This is spec-only. The intent has always been the same, we just haven't specified it very well.
The analyzer does the right thing, the front-end has a known missing compile-time error (#32557).

Member

lrhn commented Sep 15, 2018

This is spec-only. The intent has always been the same, we just haven't specified it very well.
The analyzer does the right thing, the front-end has a known missing compile-time error (#32557).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment