PM design question: Scopes
Brian Goetz
brian.goetz at oracle.com
Mon Nov 20 18:55:56 UTC 2017
On 11/20/2017 1:33 PM, Guy Steele wrote:
> I like this. One question: what does this new theory have to say
> about the situation
>
> switch (x) {
> case Foo(int x):
> int y = x;
> // fall through
> case Bar(int x, int y):
> …
> }
In this case, I would say that the second y is shadowing the first, and
therefore this is an error. Trying to merge the ys seems like a heroic
measure. Merging the xs, on the other hand, is clean, because at the
point where the second x is bound, the first x is DU (we'd skip over the
Bar(int x, int y) binding if we had matched the first case.)
The opposite example is also interesting:
case Foo(int x, int y):
// A
// fall through
case Bar(int x):
// B
Here, y is in scope in A, but not in B; x is in scope in both A and B.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/amber-spec-experts/attachments/20171120/5a2a4123/attachment.html>
More information about the amber-spec-experts
mailing list