Some inconsistencies when using Or matching
- Dominant language
- Julia
- Stars
- 320
- Forks
- 84
- PR merge metrics
- No merged PRs in 30d
Description
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
julia> @capture(:(begin; x = 2;y=3; end), begin body_ end)
true
julia> body
quote
#= REPL[2]:1 =#
x = 2
#= REPL[2]:1 =#
y = 3
end
```
matches, but the following
```julia
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
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the @capture entry point and reproduce the two-expression and one-expression examples from the issue. Trace how the Or pattern handles begin blocks and add a regression test for both cases; done means the combined pattern matches whenever the standalone begin pattern matches.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100