-
Notifications
You must be signed in to change notification settings - Fork 695
Change the result type of the unreachable operation to be the same as nop. #654
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
Comments
All unconditional control flow transfer operators (
|
@rossberg-chromium Thank you I forgot about How necessary is it to allow these operators in places that expect a value? The only case that comes to mind might be the last expression in a block in the fall-through position, but I would need to think this through? Even the proposed
Just as the following is currently valid:
If the consumer of
Also perhaps it is reasonable to expect the above to be written as:
Given the drive to keep the runtime as simple as possible, and the foot-gun that the unreachable type seems to be, this is the change I am proposing. Wouldn't it be nice to avoid the unreachable type? Might this be worth the small extra burden on consumers to emit the above work-around patterns to keep the type system happy? Some counter use cases or examples would help if I am still missing the point? I'll try making the change and test some code and see what breaks and what work-arounds would look like. |
As I said, this is both useful and standard behaviour in expression languages: branches where one case produces a result value and the other aborts in some manner are not that rare, and there is no reason not to allow them. Why put artificial extra burden on producers? Moreover, if we typed
would no longer type-check under your extended proposal. |
@rossberg-chromium The example of a trailing A. If the wasm principle is to strip the language to the core low level requirements while moving work and complexity to the producer then this change seems consistent with that principle. It seems strictly unnecessary to allow B. If implementers are prepared to trade off some complexity for more flexible expression support then the C. The feedback that I see on the multiple-value support is that it will basically give up on the 'expression' pattern, have |
Re-focusing on wasm without expressions where this is not relevant. |
Allowing the result of the
unreachable
operation to be consumed introduces a type for this in a bottom up types system. Perhaps it could be modified to be invalid to use this operation in a context that expects a value. Perhaps this is equivalent to changing it to be effectively(new_unreachable) == (block (current_unreachable) (nop))
? This might remove one type from the bottom up type system, remove theANY
type that some implementations are currently using?It might also match it's use in a virtual instruction set in which it writes to no registers.
What do people think?
The text was updated successfully, but these errors were encountered: