google / google/closure-compiler
[request] How to annotate failure or ⊥?
Open
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
How can you annotate a function that "fails" / returns the [bottom type](https://en.wikipedia.org/wiki/Bottom_type) ⊥ / "always throws an exception"? For example:
```js
function panic (e) { console.error('panic: ' + e); throw new Error(e) }
```
While its return type is naively void, it's really `⊥`. Code directly following an invocation of `panic(e)` can be assumed to never run. And code following a branch can safely assume that any conditions that would've led to `panic(e)` were false. Knowing this, a compiler can often make extreme optimizations.
If it doesn't exist, could you add a failure annotation?
Contributor guide
Assessment
This issue has not been assessed yet.