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
I have tried using the GUI with a custom comparator and it behaves... weird.
Let's use the following code for my repro:
from Standard.Base import all
from Standard.Table import all
type My_Type
Value x
score self = -self.x
to_display_text self = self.to_text
type My_Comparator
hash x = Nothing
compare x y = Ordering.compare x.score y.score
Comparable.from (_ : My_Type) = My_Comparator
main =
v = [My_Type.Value 1, My_Type.Value 3, My_Type.Value 2]
vs = v.sort
t = Table.new [["X", v]]
c = Comparable.from v.first
IO.println v
IO.println vs
IO.println c
t.print
When run in CLI, all runs fine - the vector and Table get sorted fine.
When opened in GUI, at first it also seems OK.
comparator-interactive.mp4
However, once I delete the original order_by node and add it again. After some attempts - it starts failing with Incomparable_Values.
It is as if Table.order_by seems to be no longer resolving the Comparable.from I defined for My_Type, and so it is falling back to Default_Comparator and yielding the Incomparable_Values because of that.
Curiously, after running into this error, I tried computing Comparable.from v.firstagain and the second computation indeed shows the Default_Comparator instead of My_Comparator like the old one.
The text was updated successfully, but these errors were encountered:
@radeusgd, can you please check whether the behavior still present in recent releases? I am not aware of any fixes related to this problem, but there have been hundreds of small changes that may change the behavior somehow. Thank you. Reopen if the faulty behavior persists.
I tried updating the example to the new changes (e.g. the fix that enforces the type of value returned from Comparable.from conversion). I can no longer reproduce the problem.
I have tried using the GUI with a custom comparator and it behaves... weird.
Let's use the following code for my repro:
When run in CLI, all runs fine - the vector and Table get sorted fine.
When opened in GUI, at first it also seems OK.
comparator-interactive.mp4
However, once I delete the original
order_by
node and add it again. After some attempts - it starts failing withIncomparable_Values
.It is as if
Table.order_by
seems to be no longer resolving theComparable.from
I defined forMy_Type
, and so it is falling back toDefault_Comparator
and yielding theIncomparable_Values
because of that.Curiously, after running into this error, I tried computing
Comparable.from v.first
again and the second computation indeed shows theDefault_Comparator
instead ofMy_Comparator
like the old one.The text was updated successfully, but these errors were encountered: