-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Mutable strings are unsound with (make-predicate "abc") #487
Comments
Subtyping for strings needs to keep mutability into account. In other words if the type |
@AlexKnauth True, If I understand you correctly, "abc" should be interpreted as Also, my type above |
There are two possibilities, based on different interpretations of what
|
This seems somewhat related to racket/racket#2179. |
What version of Racket are you using?
6.7.0.4
What program did you run?
What should have happened?
make-predicate should refuse to generate the predicate, as it needs a non-flat contract.
I think it's best to wait until immutable data structures are implemented in TR before fixing this, as this may otherwise break programs which rely on make-predicate (and string mutations are exceedingly rare). Then it will be possible to write
(make-predicate (∩ Immutable "abc"))
or something similar.The type of the generated predicate can also be changed to
(-> Any Boolean : #:+ "abc" #:- (or (not "abc") Mutable))
, although that goes against the general pattern for make-predicate which always generates(-> Any Boolean : T)
. Maybe it would be interesting in the future to have weaker versions(make-pos-predicate T)
which returns a predicate with the type(-> Any Boolean : #:+ T)
and(make-neg-predicate T)
which returns a predicate with the type(-> Any Boolean : #:- T)
?The text was updated successfully, but these errors were encountered: