Skip to content
This repository has been archived by the owner on Sep 27, 2019. It is now read-only.

issues with field initializers #108

Open
ericlippert opened this issue Sep 7, 2017 · 1 comment
Open

issues with field initializers #108

ericlippert opened this issue Sep 7, 2017 · 1 comment

Comments

@ericlippert
Copy link
Contributor

The grammar and semantics of field initializers are not quite right in chapter 10.

  field-initializer:
    single-quoted-string-literal  =>  expression
    integer-literal  =>  expression
    qualified-name  =>  expression
    scope-resolution-expression  =>  expression

First, integer literals are -- bizarrely -- not legal on the left side of a field initializer. Named constants that have integer values are legal, which falls under "qualified name". "integer-literal" should be removed.

Second, double-quoted string literals are legal on the left side, provided that they do not contain any evaluated expressions. So "X" would be legal, but "$x" would not. We should add a note to that effect.

@ericlippert
Copy link
Contributor Author

We should note also that there are other restrictions on the contents of the literal strings. For example '123' and '2hello' are not legal; the strings may not begin with a number. I'm not sure exactly what all the restrictions are; we should enumerate them and put them in the spec.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant