Skip to content

Disallow arrays as the RHS of a constant value definition (SLS 4.1) #9690

Open
@scabug

Description

@scabug

SLS 4.1 currently allows all types of constant expression to be the RHS of a constant value definition. This includes literal arrays and identifiers of constants which in turn are literal arrays.

However, as discussed in #3183 and recently on Gitter, the compiler actually does not treat final val definitions of literal arrays as "true" constants, because (as far as I understand) it appears difficult/impossible to ensure that they are actually not mutated.

After discussion with @retronym, the suggestion is to update the spec to clarify that literal arrays (and identifiers of constants which in turn are literal arrays) are not valid expressions for a constant value definition (although they would continue to be valid constant expressions in their own right).

/cc @som-snytt [~lihaoyi] @lrytz

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions