FluxML / FluxML/MacroTools.jl

Reassigning Variables within @capture

Open
#94 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
320
Forks
84
PR merge metrics
No merged PRs in 30d

Description

`@capture` introduces assignments to variables indicated in its second argument. When one of these assignments is to a variable with the same name as the first argument, things seem to go wrong — the match fails and the value of that variable is set to `nothing`. I think the better behavior in this case would be for the match to succeed, and for `ex` and `b` in the second example to have the values of `a` and `b` in the first.

```
julia> ex = :(1 + 2)
:(1 + 2)

julia> @capture(ex, a_ + b_)
true

julia> @capture(ex, ex_ + b_)
false

julia> ex
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.