facebookincubator / retrie

Retrie is a powerful, easy-to-use codemodding tool for Haskell.
MIT License
502 stars 30 forks source link

Incorrect code produced due to missing parentheses #67

Closed watashi closed 5 months ago

watashi commented 5 months ago

Retrie may produce incorrect code due to missing parentheses in some cases. This is actually covered by an existing test case:

https://github.com/facebookincubator/retrie/blob/main/tests/inputs/Parens.test#L24-L26

-baz2 = foo * bar
+baz2 = (3 + 4) * 5 * foo

while this example seems to be correct, note that we don't have the knowledge that (*) is associative. If we update the test case with quot, we will see obvious wrong result (see #68):

-baz2 = foo `quot` bar
+baz2 = (3 + 4) `quot` 5 `quot` foo