-
Notifications
You must be signed in to change notification settings - Fork 38
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
predicate literals lead to undecidable problem in static analysis #66
Comments
Are predicates intended for static type analysis? |
We need to make a distinction here: The special Predicate literals are NOT intended for static analysis. Instead, they're intended to enhance runtime type checking capabilities in combination with tools like We should separate predicate literals and warn that they introduce dependent types and should have a very restricted use. Open to PR suggestions. |
Wow, reading the readme I did not recognize/understand that predicate literals are different to |
Definitely open to PR suggestions to address these issues. Thanks for all your recent help, @maiermic. I really appreciate it. |
I'm pretty sure the same dependent type problem exists with regular expression literals, right @maiermic? |
Also, the special We are knowingly limiting static analysis capabilities in order to enhance runtime capabilities and analysis. That said, people who want analyzable static types are free to use a static-safe subset. That may be the best approach in the documentation: Clarify the types to avoid if you want to use the static-safe subset? =) |
We should re-organize the README so that the static-unsafe types are clearly distinguished. |
Why not? |
|
type checking on
|
True, you could do that. But a type checker could make exactly the same assumption about an untyped variable. Further, your example should not necessarily cause an error, because that would break a lot of existing code. It would also force boilerplate into every function that uses any parameter of type Hence, |
That's why I'd like to make
Although my thinking seems radical, I just like to hint at some concerns regarding static type analysis. In my opinion it leads to problems if the super type |
This is not currently the case. |
Yes, as well as |
|
👍 |
@ericelliott late answer to your question
Yes, indeed! |
predicates may be used in an interface
They introduce dependent types:
Furthermore,
Integer
is rather a type than a characteristic of a value. What is the type of the resultc
inCatchy question! You get an error.
+
is not defined forInteger
and we do not know thatInteger
is aNumber
. We need to add the typeNumber
to the parameter of the predicate to provide this information:What is the type of
c
now? Since+
is not defined forInteger
but forNumber
,c
is of typeNumber
. If we like to passc
to a function that takes anInteger
we have to do a manually type check before. Otherwise, we cann't do static type analysis in a safe way.The text was updated successfully, but these errors were encountered: