Skip to content

[TM-7] Fix PAPAIR and UNPAIR macros expantion

Ilya Peresadin requested to merge pva/tm7-fix-pair-macro into master

Description

Within testing of TM-12, some bugs were discovered in PAPAIR and UNPAIR macro expansion.

Implementation of PAPAIR and UNPAIR macros followed the Michelson specification, which states:

> UNPAIR / S => DUP ; CAR ; DIP { CDR } / S
> UNPA(\right)R / S => UNPAIR ; DIP (UN(\right)R) / S
> UNP(\left)IR / S => UNPAIR ; UN(\left)R / S
> UNP(\left)(\right)R => UNPAIR ; UN(\left)R ; UN(\right)R / S

The last line here is invalid, it's fixed. Also 2nd and 3rd line can be improved, using CAR and CDR with annotations.

Also, it states:

> PA(\right)R / S => DIP ((\right)R) ; PAIR / S
> P(\left)IR / S => PAIR ; (\left)R / S
> P(\left)(\right)R => (\right)R ; (\left)R ; PAIR / S

Last two lines seem to be invalid.

I've decided that we should merge fix of these bugs regardless whether we merge TM-12 or not. Test also fixed (previously they didn't test anything reasonable).

Also bug in contract/slashlambda.mtz was found and fixed.

https://issues.serokell.io/issue/TM-7

Checklist for your Merge Request

Related changes (conditional)

  • Tests

    • 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

    • I checked whether I should update the docs and did so if necessary:

Stylistic guide (mandatory)

Edited by Ilya Peresadin

Merge request reports