Closed aliang8 closed 7 years ago
This is not cool. The reason why we're not matching fractions when there's a minus is b/c the minus is a neg node wrapping the division so it doesn't look like division to the matcher. We can unwrap neg nodes to check if there's a fraction, but it's unclear to me how to communicate information about signs to the rewrite pattern.
I'm going to fix this for variable length patterns such as ADD_NUMERATORS
, but not for fix length patterns such as REMOVE_ADDITION_OF_ZERO
. This is to save time, but also to isolate any weird side effects there may be of making this change.
Example:
['2/3 - 2/3', '(2 - 2) / 3']
['2/4 - 4/4 - 6/4', '(2 - 4 - 6) / 4']
TypeError: Cannot read property 'node' of null
because it cannot find thematchPattern
[UPDATE] Also fails for
REMOVE_ADDITION_OF_ZERO
E.g
2 - 0 => 2
, same error