# Clarify specification of allowable symbols in constant expressions #34464

Open
opened this Issue Sep 14, 2018 · 3 comments

Projects
3 participants
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".

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; } }
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?
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).