[TM-354] Optimizer depends on tree structure of its input
Description
Inside test/Test/Optimizer.hs there's
unit_UNPAIR_DROP :: Assertion
unit_UNPAIR_DROP = do
optimize @Stack1Pair @Stack1 (DUP `Seq` (CAR `Seq` (DIP CDR `Seq` DROP))) @?= (DUP `Seq` CAR `Seq` DROP `Seq` CDR)
If we change the order of brackets to
optimize @Stack1Pair @Stack1 (((DUP `Seq` CAR) `Seq` DIP CDR) `Seq` DROP) @?= (DUP `Seq` CAR `Seq` DROP `Seq` CDR)
then test consequently fails meaning that the sequence passed to optimizer depends on its tree structure which should not. There's already written flattenning function Michelson.Optimizer.flattenSeqLHS which consequently needs to be refactored. So this MR resolves the problem of optimizer's tree-dependence.
Related issue(s)
https://issues.serokell.io/issue/TM-354
✅ Checklist for your Merge Request
Related changes (conditional)
-
Tests (see short guidelines)
-
If I added new functionality, I added tests covering it. -
If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
-
-
Documentation
Stylistic guide (mandatory)
-
My commits comply with the following policy. -
My code complies with the style guide.
Edited by Anton Myasnikov