-
Notifications
You must be signed in to change notification settings - Fork 55
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
Remove type based duplicates #745
Remove type based duplicates #745
Conversation
collapse_bind returned nothing if last non-deterministic branch returned empty result. This commit fixes the behavior by adding a dummy non-empty branch which returns result not included into collapse_bind results.
Interpreter and type-checking code treat calls of the functions without type declared differently. Type checker represents this call as a tuple type. But interpreter calls it thus effectively treating it as %Undefined% type. This commit adds %Undefined% to the list of types for tuples which are not function calls removing the difference.
Before this logic got the types of the function and tried to apply each to the parameter's types. Thus each time effectively evaluating the function result with the given function type. It leads to the duplication of the function results when the same function has few different type signatures (non-deterministic type). This commit changes behavior. New behavior is filtering list of the function type by checking if type is applicable to the parameter's types first. Then get any type from the list and call the function using this type.
This also blocks #668 from merging. |
!(assertEqualToResult | ||
(f (+ 5 "S")) | ||
((Error "S" BadType))) | ||
; TODO: This test has different behavior in old_interpreter and minimal interpreter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I like the new behavior better
!(assertEqualToResult | ||
(get-type (fmap (curry-a + 2) (UntypedC (Null) 5))) | ||
()) | ||
; Two examples below are type-checked successfully because, (UntypedC "5") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. The type of (UntypedC "5")
should be reducible to %Undefined%
meaning that the whole expression can type-check. I'd add "FIXME" or "TODO", because we may need to revisit these tests and uncomment their updated versions
Fixes #235. Type checking behavior is changed (see tests
c1_
,d2_
andd5_
. In particular for the case like:previous behavior was to return the most inner type error, i.e.
(Error "S" BadType)
, now interpreter returns less inner type error, i.e.(Error (+ 5 "S") BadType)
. I am not sure whether one should be preferred over another.