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
Typically, if @capture(expr, match_1) matches you would expect @capture(expr, match_1 | match_2) to always also match. This is however not the case. For example:
julia>@capture(:(begin; x =2;y=3; end), begin body_ end)
true
julia> body
quote#= REPL[2]:1 =#
x =2#= REPL[2]:1 =#
y =3end
matches, but the following
julia>@capture(:(begin; x =2;y=3; end), begin body_ end|for i_ in iter_ forbody_ end)
false
does not. In addition, it the expression in the block only contains one expression, there will be a match:
julia>@capture(:(begin; x =2; end), begin body_ end|for i_ in iter_ forbody_ end)
true
julia> body
:(x =2)
This feels inconsistent to me.
The text was updated successfully, but these errors were encountered:
Agreed that it's inconsistent. Not sure which way we should resolve it though.
julia>@capture(:(begin; x =2;y=3; end), begin body_ end)
true
felt surprising to me, but at the same time I can kinda see the reasoning behind it. I'm a bit worried that if we changed that to false, we'd break people's code somewhere, and might learn the original reason for this behaviour.
So that leaves us with making
julia>@capture(:(begin; x =2;y=3; end), begin body_ end|for i_ in iter_ forbody_ end)
false
Typically, if
@capture(expr, match_1)
matches you would expect@capture(expr, match_1 | match_2)
to always also match. This is however not the case. For example:matches, but the following
does not. In addition, it the expression in the block only contains one expression, there will be a match:
This feels inconsistent to me.
The text was updated successfully, but these errors were encountered: