-
Notifications
You must be signed in to change notification settings - Fork 323
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
case of and intersection types #11850
Conversation
...ntime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/IsValueOfTypeNode.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Gregory Michael Travis <greg.m.travis@gmail.com>
.../src/main/java/org/enso/interpreter/node/expression/builtin/error/GetStackTraceTextNode.java
Show resolved
Hide resolved
@@ -295,7 +295,7 @@ Error.should_equal self that frames_to_skip=0 = | |||
Number.should_equal : Float -> Float -> Integer -> Spec_Result | |||
Number.should_equal self that epsilon=0 frames_to_skip=0 = | |||
matches = case that of | |||
_ : Number -> self.equals that epsilon | |||
n : Number -> self.equals n epsilon |
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.
This shows a small nuance. Previously there was no difference between that
and n
. Now there is as 571cce6 documents.
…ude all types or not
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.
Please document all non-trivial logic
.../src/main/java/org/enso/interpreter/node/expression/builtin/error/GetStackTraceTextNode.java
Show resolved
Hide resolved
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.
Looks good altogether. I have two questions though. The first one about incosistency is more important:
(1)
So type pattern branches in case of expressions don't do automatic conversions, as opposed to standard method calls.
i.e.,
a = A:A
case a of
b: B -> "Is a B"
will not match. In other words, case expressions uncover the hidden parts of multivalue, but they don't uncover the types that the scrutinee
can be cast to. I find this slightly confusing. Consider this code:
method (b:B) = b.b
main =
a = A:A
ax = A:A&X
res1 = case ax of
b: B -> b.b
_ -> "Else"
res2 = method ax
[res1, res2]
res1
will be "Else", while res2
will be "b". The same thing will happen if ax
is replaced with a
in the case expression and method call. What is the reason for this incosistency?
(2)
Any plans to support intersection types in type patterns as well?
case ax of
_: A&X -> ...
fails with:
/home/pavel/tmp/tmp.enso:27:12: error: Syntax is not supported yet: qualifiedNameSegment.
27 | _: A&X -> "Is A&X"
| ^~~
Pull Request Description
Fixes #11828 by enhancing the
case of
nodes to recognize additional types ofEnsoMultiValue
.Important Notes
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,