From 2152cfdea76e6c360e7c3243752cf5f146b63264 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Wed, 4 Dec 2024 11:13:47 +0200 Subject: [PATCH 1/4] Fix some typos in the static access shorthand proposal --- .../proposal-simple-lrhn.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/working/3616 - enum value shorthand/proposal-simple-lrhn.md b/working/3616 - enum value shorthand/proposal-simple-lrhn.md index 9074a1d4bc..74d6406301 100644 --- a/working/3616 - enum value shorthand/proposal-simple-lrhn.md +++ b/working/3616 - enum value shorthand/proposal-simple-lrhn.md @@ -37,7 +37,7 @@ We introduce grammar productions of the form: ::= ... -- all current productions | -- No selectors, no `.new`. - ::= + ::= * ::= @@ -91,7 +91,7 @@ Future 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 `` production ` *`, -and now also ` `. +and now also ` *`. The new grammar is added as a separate production, rather than making `` a ``, and sharing the `*` @@ -163,7 +163,7 @@ First, when inferring types for a `` of the form `` with context type scheme *C*, then assign *C* as the shorthand context of the leading ``. Then continue inferring a type for the entire `` -recursively on the chain of selectors of the ``, +recursively on the chain of selectors of the `*`, in the same way as for a ` *`. _This assigns the context type scheme of the entire, maximal selector chain to the static member shorthand head, moving it past any intermediate ``s._ @@ -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 .new\<*typeArgs*\> or +Expressions of the forms .new\<*typeArgs*\>(*args*) or .new\<*typeArgs*\> (as a prefix of a ` *` production, or the entire chain) are compile-time errors, just like -the corresponding *T*.new\<*typeArgs*\> +the corresponding *T*.new\<*typeArgs*\>(*args*) and *T*.new\<*typeArgs*\> already are, whether used as instantiated tear-off or invoked. _(The grammar allows them, because `C.new` is a `` expression, but From 29e8392b8314b289cfd43ea7fba22325941aff44 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Fri, 6 Dec 2024 12:26:21 +0200 Subject: [PATCH 2/4] Add != pattern to 'Special case for ==' --- .../3616 - enum value shorthand/proposal-simple-lrhn.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/working/3616 - enum value shorthand/proposal-simple-lrhn.md b/working/3616 - enum value shorthand/proposal-simple-lrhn.md index 74d6406301..c1e3d11b5a 100644 --- a/working/3616 - enum value shorthand/proposal-simple-lrhn.md +++ b/working/3616 - enum value shorthand/proposal-simple-lrhn.md @@ -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 `` expression, -then assign the type *S1* as the shorthand context of the `` -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 `` +expression, then assign the type *S1* as the shorthand context of the +`` 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 From 28508f7089a37b5e630a5bc4687714da9757e1c0 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Mon, 23 Dec 2024 12:24:12 +0200 Subject: [PATCH 3/4] Remove accidental text --- working/3616 - enum value shorthand/proposal-simple-lrhn.md | 1 - 1 file changed, 1 deletion(-) diff --git a/working/3616 - enum value shorthand/proposal-simple-lrhn.md b/working/3616 - enum value shorthand/proposal-simple-lrhn.md index c1e3d11b5a..df9e67ca98 100644 --- a/working/3616 - enum value shorthand/proposal-simple-lrhn.md +++ b/working/3616 - enum value shorthand/proposal-simple-lrhn.md @@ -393,7 +393,6 @@ a static declaration or constructor declaration *S* when looked up on *D*. or the added type arguments are constant types. _Static tear-offs are constant. Instantiated static tear-offs are constant if the inferred type arguments are._ - that is not a constant expression.)_ * An expression of the form `.new` which is not followed by the selectors of an ``, is a constant expression if *S* declares a constant (unnamed) constructor, and either type From b30ef7836f3e3532f98925e00d98ca90cac03353 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Mon, 23 Dec 2024 15:31:33 +0200 Subject: [PATCH 4/4] Remove accidental character --- working/3616 - enum value shorthand/proposal-simple-lrhn.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/working/3616 - enum value shorthand/proposal-simple-lrhn.md b/working/3616 - enum value shorthand/proposal-simple-lrhn.md index df9e67ca98..5f4b2baa71 100644 --- a/working/3616 - enum value shorthand/proposal-simple-lrhn.md +++ b/working/3616 - enum value shorthand/proposal-simple-lrhn.md @@ -387,7 +387,7 @@ a static declaration or constructor declaration *S* when looked up on *D*. * An expression of the form `.` is a constant expression if *S* declares a constant getter. * An expression of the form `.` that is not followed by an - ``, is a constant expression if `*S* declares + ``, is a constant expression if *S* declares a static method or constructor, and either type inference has not added type arguments as a generic function instantiation coercion, or the added type arguments are constant types.