Skip to content
This repository has been archived by the owner on Aug 17, 2022. It is now read-only.

Need some way to declare thrown exceptions? #2

Closed
tlively opened this issue Aug 21, 2019 · 4 comments
Closed

Need some way to declare thrown exceptions? #2

tlively opened this issue Aug 21, 2019 · 4 comments

Comments

@tlively
Copy link
Member

tlively commented Aug 21, 2019

Although the exceptions a function can throw are not part of its type, they are part of its contracts with its callers. It would be unfortunate if we could not reason about this part of a module’s ABI when checking that a module inhabits a module type. For example, modules that inhabit the same module type should ideally be drop-in replacements for each other, but if they can throw exceptions with different tags or types then they may not actually be interchangeable after all.

It’s possible that these concerns should not be addressed at the level of this proposal, though. This might be a consideration for interface types instead.

@rossberg
Copy link
Member

Until the exception proposal lands there doesn't seem much to say. Once Wasm has exceptions, corresponding effect annotations are an interesting consideration, but it is not obvious that they would be useful. The Wasm type system itself doesn't check exception effects, so they would be little more than unchecked comments in a module type.

Since module types are intended to reflect the core Wasm type system only, I agree that interface types are probably a more adequate place to have such a mechanism. But even there it might not provide more than documentary value.

@lukewagner
Copy link
Member

lukewagner commented Aug 21, 2019

FWIW: given that exceptional values will often contain pointers into linear memory (e.g., the string payload of a C++ std::runtime_error) and a general goal of interface types is to allow linear memories to be encapsulated when composing modules, it would follow that it's within interface types' purview to include mechanisms for adapting exceptions that propagate through a cross-interface call.

But agreed that, because module types simply capture the types of functions in a module, that unless wasm function types (core or with interface types) get an exception effect in their type, it wouldn't make sense for module types to have one. So maybe the place to ask this question is in the exception-handling repo: should be exception specifications?

@PoignardAzur
Copy link

Relevant issue.

I definitely think there should be exception specifications. It's the direction most languages have been moving towards.

@tlively
Copy link
Member Author

tlively commented Aug 21, 2019

Ok, thanks everyone. Closing in favor of continuing discussions elsewhere.

@tlively tlively closed this as completed Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants