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
Initially, I used a custom type related to my project, but after repeated failures of the matcher, I tried the tutorial examples - to make sure I was not doing something wrong.
Specifically, the evaluation of the following snippet goes wrong:
@data Color beginRGB(r::Int, g::Int, b::Int)
Gray(Int)
end@as_record RGB
@as_record Gray
color_to_int(x) =@match x beginRGB(;r, g, b) =>16+ b +6g +36r
Gray(i) =>232+ i
end
When calling RGB(200, 0, 200) |> color_to_int I get an error complaining about matching not being exhaustive.
I redefined the expression in the following way:
color_to_int(x) =@match x beginRGB(;r, g, b) =>16+ b +6g +36r
Gray(i) =>232+ i
_ =>10end
Now, the execution of RGB(200, 0, 200) |> color_to_int runs successfully - however, the output is 10.
It seems that the deconstruction of RGB(200, 0, 200) fails to be recognized as a valid RGB(;r, g, b) pattern.
I am using Julia 1.8.2 with MLStyle v0.4.15 inside Pluto v0.19.9.
The text was updated successfully, but these errors were encountered:
@data Color beginRGB(r::Int, g::Int, b::Int)
Gray(Int)
end@as_record RGB
@as_record Gray
color_to_int(x) =@match x beginRGB(;r, g, b) =>16+ b +6g +36r
Gray(i) =>232+ i
end
Sorry, using this snippet gives me RGB(200, 0, 200) |> color_to_int == 7416.
Could you please provide versioninfo() using your test environment?
Initially, I used a custom type related to my project, but after repeated failures of the matcher, I tried the tutorial examples - to make sure I was not doing something wrong.
Specifically, the evaluation of the following snippet goes wrong:
When calling
RGB(200, 0, 200) |> color_to_int
I get an error complaining about matching not being exhaustive.I redefined the expression in the following way:
Now, the execution of
RGB(200, 0, 200) |> color_to_int
runs successfully - however, the output is 10.It seems that the deconstruction of
RGB(200, 0, 200)
fails to be recognized as a validRGB(;r, g, b)
pattern.I am using Julia 1.8.2 with MLStyle v0.4.15 inside Pluto v0.19.9.
The text was updated successfully, but these errors were encountered: