(match
[[1 2 3]]
[(:or [_ _ 2]
[3 _ _])] :a0
[(:or [_ _ 1]
[1 _ _])] :a1
:else :else)
=> :else
In this first snippet I expected it to return :a1.
Weird.
This works:
(match
[[1 2 3]]
[(:or [_ _ 2]
[1 _ _])] :a0
[(:or [_ _ 1]
[3 _ _])] :a1
:else :else)
=> :a0
Is this an expected behaviour?
I believe this is a bug in
specialize-or-pattern-row. I believe thegroupable?test there is wrong because, in your case, it succeeds for your twoOrPatterns, and so the secondOrPatternis replaced with the expansion of the first (thepsare the subpatterns of the firstOrPattern).You could work around this by adding a dummy pattern to your second
:orwhich will forcegroupable?to return false:A possibly better
specialize-or-pattern-row(copy-asis there to preserve any:asmetadata on the overallOrPatternby copying the:ason to each of the subpatterns):