-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
define-metafunction does not check type signature on LHS #255
Comments
Thanks for the interest in Redex! Unfortunately, the signatures on metafunctions (and similar things in other places) aren't something that redex can reason about statically in a definitive manner. That is, redex currently can only checks that a particular term matches a pattern, not the relationship between two patterns. I suppose it would be possible, when discovering that In the fully general case, the question of what the relationship between two patterns (do they have an empty intersection, is one a subset of the other?) are not things that I know how to compute. If you have ideas on what such an algorithm would look like, I'd be interested! There is already some code (see the |
That I don't think it changes anything to check one LHS against all the other LHSs, since this is still a pattern-pattern check. My recommendation would be to check the LHSs against the function signature if provided, and otherwise just allow everything. Errors only occur if it is possible to prove that the function signature pattern has empty intersection with the LHS. (You can also do the same checks in RHSs, where clauses and probably many other places.) The part I struggled with when poking around the code was whether it is possible to run this check at "compilation time" because it seems like |
Well, trying to use overlapping-patterns will quickly lead to an understanding of what's insufficient about it. 😄 The way Redex works, you'd extract all the patterns and turn them into the internal format of the patterns at compile time. But then it is probably simplest to do the actually checking when the metafunction definition is evaluated. And just in the interest of clarity, I'm not sure this is something I'm really ready to take on as I don't see it as the major problem with redex currently, but it is also a non-trivial project. |
Ideally, the clauses in the definition of
flip
would be rejected because()
does not match the grammarN
, so they can never be used correctly. Checking#:pre
and#:post
conditions would also be great, but I'm not sure this is possible. (Also I wouldn't be too surprised if it is possible to write expressions that can't be typechecked at function declaration time, but there are lots of examples like this one where the pattern definitely has empty intersection with the grammar, so an error message seems warranted.)The text was updated successfully, but these errors were encountered: