-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
require/typed #opaque -> contract violation #456
Comments
This warning is caused by my fix to #379 |
So the All is on the predicate contract. Does that make every opaque import a violation? The value is a pointer, so, inherently unsafe. Can we get an #:unsafe-opaque import for that case? |
Yes, specifically it's coming from the As an unsafe workaround you can use (unsafe-require/typed "untyped.rkt"
[#:opaque XPointer x-pointer?])
(require/typed "untyped.rkt"
[make-x (-> XPointer)]
[take-x (-> XPointer Void)]) |
I'll try that. BTW, I'm using 6.5 now, with the #:opaque. I (accidentally) introduced a cpointer tag with an _ prefix in one module and without _ prefix in another module. The #:opaque predicate caught the bug. So a little fighting with typed racket + ffi is paying off. |
That works in 6.7. I don't think I understand your comment, "from the |
If you're importing the (x-pointer? (λ ([x : Fixnum]) (+ x 1))) The lambda there is a typed value, and without a guard there, that typed value would flow into untyped code, which could call that function. Your predicate will not do that; it will return |
Thanks. I understand. To avoid
I don't know if that is actually feasible. |
The thing is, it's not really However if you only have the program |
@AlexKnauth Thanks for your help with this issue. Anyone looking for an example of this usage can check out: https://github.com/acarrico/wayland-protocol/tree/master/typed/wayland-0 |
I think this still can be improved. For values coming from the untyped side, it shouldn't need to wrap it before passing the untyped value into the untyped predicate. What I don't know is whether we would then have to wrap it after the predicate returns true, before letting it through into typed code. Right now we don't; could we still get away with not doing that if we took the wrapping away in the other place? |
I think that the denotation you have in mind is that Instead, the denotation I have in mind is that untyped to typed borderTest the untyped value with the untyped predicate.
|
I say we are "always safe", but is there anything you can do with an Consider |
The way On the untyped to typed border, I agree that we can use the untyped predicate, and I don't think we need On the typed to untyped border, again I agree that we don't need to use the predicate, but here I'm not sure whether or not For |
I have an example of why we need |
This issue has been mentioned on Racket Discourse. There might be relevant details there: https://racket.discourse.group/t/coerce-f-and-pointer-in-typed-racket/2580/5 |
As detailed in test case: https://gist.github.com/acarrico/850f9d7112104afd3e5a6dd916edf1ae
Succeeds in Racket 6.2, fails with contract violation in 6.6, 6.7.
The text was updated successfully, but these errors were encountered: