Skip to content
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

Fix some typos in the static access shorthand proposal #4194

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions working/3616 - enum value shorthand/proposal-simple-lrhn.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ We introduce grammar productions of the form:
<constantPattern> ::= ... -- all current productions
| <staticMemberShorthandValue> -- No selectors, no `.new`.

<staticMemberShorthand> ::= <staticMemberShorthandHead> <selector*>
<staticMemberShorthand> ::= <staticMemberShorthandHead> <selector>*

<staticMemberShorthandHead> ::=
<staticMemberShorthandValue>
Expand Down Expand Up @@ -91,7 +91,7 @@ Future<String> futures = .wait([lazyString(), lazyString()]).then((list) => list
This is a simple grammatical change. It allows new constructs in any place where
we currently allow primary expressions followed by selector chains
through the `<postfixExpression>` production `<primary> <selector>*`,
and now also `<staticMemberShorthandHead> <selector*>`.
and now also `<staticMemberShorthandHead> <selector>*`.

The new grammar is added as a separate production, rather than making
`<staticMemberShorthandHead>` a `<primary>`, and sharing the `<selector>*`
Expand Down Expand Up @@ -163,7 +163,7 @@ First, when inferring types for a `<postfixExpression>` of the form
`<staticMemberShorthand>` with context type scheme *C*, then assign *C* as
the shorthand context of the leading `<staticMemberShorthandHead>`.
Then continue inferring a type for the entire `<staticMemberShorthand>`
recursively on the chain of selectors of the `<selector*>`,
recursively on the chain of selectors of the `<selector>*`,
in the same way as for a `<primary> <selector>*`. _This assigns the
context type scheme of the entire, maximal selector chain to the static member
shorthand head, moving it past any intermediate `<selector>`s._
Expand Down Expand Up @@ -265,10 +265,10 @@ this expression may have an actual context type. If it was followed by "real" se
like `.parse(input).abs()`, then the recognized expression, `.parse(input)`
in this example, likely has no context type._

Expressions of the forms <code>.new\<*typeArgs*\></code> or
Expressions of the forms <code>.new\<*typeArgs*\>(*args*)</code> or
<code>.new\<*typeArgs*\></code> (as a prefix of a `<staticMemberShorthand> <selector>*`
production, or the entire chain) are compile-time errors, just like
the corresponding <code>*T*.new\<*typeArgs*\></code>
the corresponding <code>*T*.new\<*typeArgs*\>(*args*)</code>
and <code>*T*.new\<*typeArgs*\></code> already are, whether used as instantiated
tear-off or invoked.
_(The grammar allows them, because `C.new` is a `<primary>` expression, but
Expand Down Expand Up @@ -317,10 +317,11 @@ For `==`, we special-case when the right operand is (precisely!) a static
member shorthand.

If an expression has the form `e1 == e2` or `e1 != e2`, or a pattern has the
form `== e2`, where the static type of `e1`, or the matched value type of the
pattern, is *S1*, and *e2* is precisely a `<staticMemberShorthand>` expression,
then assign the type *S1* as the shorthand context of the `<staticMemberShorthandHead>`
of *e2* before inferring its static type the same way as above.
form `== e2` or `!= e2`, where the static type of `e1`, or the matched value
type of the pattern, is *S1*, and *e2* is precisely a `<staticMemberShorthand>`
expression, then assign the type *S1* as the shorthand context of the
`<staticMemberShorthandHead>` of *e2* before inferring its static type the same
way as above.

This special-casing is only against an immediate static member shorthand.
It does not change the *context type* of the second operand, so it would not
Expand Down
Loading