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

Option.getUnsafe does not raise #130

Closed
agarwal opened this issue Apr 14, 2023 · 2 comments · Fixed by #131
Closed

Option.getUnsafe does not raise #130

agarwal opened this issue Apr 14, 2023 · 2 comments · Fixed by #131

Comments

@agarwal
Copy link

agarwal commented Apr 14, 2023

The documentation of Option.getUnsafe gives the example:

Option.getUnsafe(None) // Raises an error

However, the following code does not raise. I see undefined printed to the console and no exception.

let x = Option.getUnsafe(None)
Js.log(j`$x`)

Why is there also an Option.getExn function? That has the expected behavior, so I'm using that for now.

@glennsl
Copy link
Contributor

glennsl commented Apr 14, 2023

The documentation is wrong. "Unsafe" here means that it's unsoundly typed, i.e. that it may return a value that does not belong to its return type, in this case undefined, which does not belong to most types you can put in an option.

@glennsl
Copy link
Contributor

glennsl commented Apr 14, 2023

Proposed fix in #131

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

Successfully merging a pull request may close this issue.

2 participants