You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This task is automatically imported from the old Task Issue Board and it was originally created by Radosław Waśko.
Original issue is here.
When writing
f e = case e of
_ : Date -> True
_ -> False
I expect such a branch to match any instance of a Date but not the Date type itself.
i.e. i'd expect
f (Date.new 1999 12 12) == True
f Date == False
however with the current implementation - both would be true!
This is inconsistent with custom defined Enso atoms where it will behave as expected for
type Foo
Bar x
I will get
g e = case e of
_ : Foo -> True
_ -> False
g (Foo.Bar 42) == True
g Foo == False
as expected.
I have checked that this is the case for at least Date and Integer types, likely for more.
Here's a more complete repro:
from Standard.Base import all
domatch v =
a = case v of
Date -> "Date type"
_ : Date -> "Date value"
_ -> "other"
b = case v of
_ : Date -> "Date value"
Date -> "Date type"
_ -> "other"
IO.println v.to_text+" -> "+[a, b].to_text
domatch2 v =
a = case v of
Integer -> "Integer type"
_ : Integer -> "Integer value"
_ -> "other"
b = case v of
_ : Integer -> "Integer value"
Integer -> "Integer type"
_ -> "other"
IO.println v.to_text+" -> "+[a, b].to_text
type Foo
Bar x
domatch3 v =
a = case v of
Foo -> "Foo type"
_ : Foo -> "Foo value"
_ -> "other"
b = case v of
_ : Foo -> "Foo value"
Foo -> "Foo type"
_ -> "other"
IO.println v.to_text+" -> "+[a, b].to_text
main =
IO.println "Matching date:"
domatch Date
domatch (Date.new 2022 10 12)
domatch 42
IO.println "Matching integer:"
domatch2 42
domatch2 Integer
domatch2 (Date.new 2022 10 12)
IO.println "Matching custom type (Foo):"
domatch3 Foo
domatch3 (Foo.Bar 42)
domatch3 42
while I'd expect to always have consistent results regardless of branch ordering here - _ : Date -> and Date -> should be completely distinct branches:
This task is automatically imported from the old Task Issue Board and it was originally created by Radosław Waśko.
Original issue is here.
When writing
I expect such a branch to match any instance of a Date but not the Date type itself.
i.e. i'd expect
however with the current implementation - both would be true!
This is inconsistent with custom defined Enso atoms where it will behave as expected for
I will get
as expected.
I have checked that this is the case for at least Date and Integer types, likely for more.
Here's a more complete repro:
I'm getting:
while I'd expect to always have consistent results regardless of branch ordering here -
_ : Date ->
andDate ->
should be completely distinct branches:Comments:
Discord discussion thread https://discord.com/channels/401396655599124480/1044380778085228564/1044380778085228564 (Radosław Waśko - Nov 21, 2022)
The text was updated successfully, but these errors were encountered: