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

Reject yielding a value to the top of a loop #277

Closed
sunfishcode opened this issue Apr 21, 2016 · 7 comments
Closed

Reject yielding a value to the top of a loop #277

sunfishcode opened this issue Apr 21, 2016 · 7 comments
Milestone

Comments

@sunfishcode
Copy link
Member

The following code currently validates in the ml-proto interpreter:

(module (func (loop (br 0 (i32.const 0)))))

This isn't useful, because the (i32.const 0) value isn't actually used, since the branch is going to the top of a loop.

I propose that this be made a validation error, both to diagnose accidental use, and to reserve room for making branches to loop tops to be extended in the future.

@ghost
Copy link

ghost commented Apr 22, 2016

That would not be consistent with the type system which discards values not consumed. What extensions do you have in mind.

@lukewagner
Copy link
Member

This change would be subsumed by the more general change to remove the void-subtyping rule (since the loop label has type void).

@ghost
Copy link

ghost commented Apr 22, 2016

@lukewagner That would seem to imply adding a discard operator? It's going to cost encoding efficiency and an expressionless encoding is already ahead. It would also be subsumed by just not returning values from blocks.

@lukewagner
Copy link
Member

A discard for the general case, yes, but also changing set_local/store to return void (maybe adding a tee to maintain the current set_local-value-returning semantics).

@rossberg
Copy link
Member

@sunfishcode, yes, this is a consequence of #271, and your complaint is the same as the original issue #179, so we already went back and forth on this one. But as @lukewagner said, with explicit drops this would be resolved for good.

@ghost
Copy link

ghost commented Apr 22, 2016

Even if a discard operator is added there is more to this. For example the following would still be valid which might not 'reserve room for making branches to loop tops to be extended in the future'.

(module (func (loop (br 0 (nop)))))

@sunfishcode sunfishcode added this to the MVP milestone Jul 8, 2016
@rossberg
Copy link
Member

This is obsolete with the new drop design.

ngzhian added a commit to ngzhian/spec that referenced this issue Nov 4, 2021
Lost the token in the parser during rebases.
ngzhian added a commit to ngzhian/spec that referenced this issue Nov 4, 2021
This got lost in the rebase too, and WebAssembly#277 only partially fixed it.
dhil pushed a commit to dhil/webassembly-spec that referenced this issue Oct 3, 2023
rossberg pushed a commit that referenced this issue Feb 28, 2024
Test that throw is polymorphic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants