In one-to-one matching, symbols that have a variable_name do not work in commutative functions. They seem to work correctly in many-to-one matching. Example:
from matchpy import Operation, Symbol, Arity, Pattern, match, ManyToOneMatcher
f = Operation.new('f', Arity.binary, commutative=True)
a_x = Symbol('a', variable_name='x')
a = Symbol('a')
b = Symbol('b')
subject = f(a, b)
pattern = Pattern(f(a_x, b))
print(list(match(subject, pattern)))
matcher = ManyToOneMatcher(pattern)
print(list(matcher.match(subject)))
This results in
[]
[(Pattern(f(a: x, b)), {'x': Symbol('a')})]
but it should result in
[{'x': Symbol('a')}]
[(Pattern(f(a: x, b)), {'x': Symbol('a')})]
So far, we don't have any tests that verify this functionality. Once it is fixed, we should add some.