-
Notifications
You must be signed in to change notification settings - Fork 20
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
Special-case raising an exception with byrefs #872
Comments
This was referenced May 26, 2020
Marking approved. I guess I don't really mind how many of those are special-cased. |
5 tasks
Would this be extended to inline functions that raise an error unconditionally? It would make it possible to define custom error functions such as the following: let inline notPositive name = raise (ArgumentOutOfRangeException(name, name + " must be greater than zero!")) |
Never mind. I just realized #688 already addresses the issue. |
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tracking as per here: dotnet/fsharp#5776
We should allow raising exceptions in
byref
-returning functions and methods, like this:The existing way of approaching this problem in F# is to insert a dummy return value to satisfy the F# compiler:
The reason why this doesn't work is that the way you raise exceptions in F# is through the
raise
function, which returns a generic value. Same goes for the other helpers:failwith
invalidArg
nullArg
invalidOp
reraise
rethrow
failwithf
Note that @dsyme is not in favor of special casing anything other thanraise
. I personally think all other thanfailwithf
should be allowed, though that may be worth considering.Pros and Cons
The advantages of making this adjustment to F# are:
The disadvantages of making this adjustment to F# are:
byref
andbyref
-like typesExtra information
Estimated cost (XS, S, M, L, XL, XXL): M
Affidavit (please submit!)
Please tick this by placing a cross in the box:
Please tick all that apply:
The text was updated successfully, but these errors were encountered: