-
Notifications
You must be signed in to change notification settings - Fork 804
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
use in Async throws on null #1231
Comments
Are you talking about Async.usingA in control.fs?
If I change it to
then we change the signature. Specifically the type paramter If I change it to
then we restrict Both create compile errors. Any ideas? |
Yes, and I noticed the same difficulty after posting the issue. I used a C# primitive to work around it. The C# primitive seems to produce the desired compile outcome on .Net (no code on a struct, simple pointer test on a class). The same CIL code sequence can probably be emitted in F# somehow. I think the |
@polytypic can you come up with a minimal struct sample that I can add as additional unit test to verify if it works? |
If you don't mind the boxing on structs there's also
|
mhm I think we need a primitive like isNull that doesn't restrict the type and does the same as polytypic's C# primitive. That one could also be exposed so that we can use it in other libs. |
I just used a Dummy struct like here. You probably also want to test that |
I just found this little gimmick in prim-types.fs:
that's not too bad, right? |
So @dsyme helped me and the PR is ready for review. |
I just noticed the discrepancy demonstrated below:
It might make sense to change the
Async.Using
method to better match core languageuse
expression semantics. The fix is trivialnull
check before callingDispose
.The text was updated successfully, but these errors were encountered: