-
Notifications
You must be signed in to change notification settings - Fork 457
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
Document behavior of label name reuse. #210
Comments
Just tested this with the spec interpreter:
No error. It seems that the spec interpreter just uses the first label it finds. |
What about:
Is this a break or continue? |
If this is the behavior we want, then I guess we should spec the label search order. I feel that relying on search order is kind of error prone. |
@mbebenita The loop block label should be the outer label, so it should see the loop repeat label. The binary encoding has no labels here, but you are right that the order should be specified. |
@JSStats I was under the impression that the loop blocks are just blocks with an additional label. So it effectively has two labels, and they are both outer labels as far as the
|
I'm in favor of disallowing the ambiguous cases (1 or 2 in the first comment). |
is sugar for
See https://github.com/WebAssembly/spec/blob/master/ml-proto/README.md#s-expression-syntax. Testing this in ml-proto:
is an infinite loop. So the search order is from "outward". |
@kripken option 2 is consistent with JS semantics, so I'd favor that as well. |
@binji ah, I see, that makes sense. |
@binji Not sure if 'outward' is meaningful. Perhaps note labels are a lexical binding, a stack, and that the lookup chooses the first in the stack, so an inner binding shadows an outer binding. But it's just for the spec wast and perhaps people would rather not have such hazards in tests etc. |
Labels have standard lexical scoping behaviour. That is, they scope over the labelled expression, and can be shadowed within their scope. The We could disallow shadowing, but I don't see a strong reason for that. Everything regarding names is not part of the "official" spec semantics anyway. |
What is the advantage? From my perspective this has disadvantages because it is unusual and mostly creates an opportunity for confusion.
This doesn't match our design history, and it feels like a semantic trick. In the context of tableswitch and a bunch of cases, the best way to describe the numbering of the |
On 21 January 2016 at 18:14, Katelyn Gadd [email protected] wrote:
Allowing shadowing ensures locality and compositionality: without it, you Everything regarding names is not part of the "official" spec semantics
Not sure why you're saying that. The AST semantics never had names, AFAIR. and it feels like a semantic trick. In the context of tableswitch and a
|
@rossberg-chromium 'locality and compositionality' seem important for a usable source code. FYI For |
Currently, the spec does not say if label name reuse is allowed or not:
f3015ed#diff-d372e456aea857e846293c5f4add7c81R156
I'm not sure what the current implemented behavior is, but I suppose there are only two options:
The text was updated successfully, but these errors were encountered: