Skip to content

[#442] Fix contracts' pretty-printer

Ilona Prikule requested to merge ixahedron/#442-fix-contract-printer into master

Description

Problem: contracts that include PUSHing a lambda-typed expression are printed misaligned using morley's printer, causing tezos-client to refuse to accept them. The problem lies in printing instructions inside the PUSH on one line, but then encountering a nested expression (e.g. DIP) and recursively pretty-printing over several lines, causing the PUSH and, consequently, the contract to be misaligned.

Solution: disambiguated how to render PUSH expressions based on their type; short values are now printed in one line as before (e.g. PUSH int 5), values that might include further instructions (like lambdas and Some) are printed with all arguments hanging, like in LAMBDA instructions. Contracts for tests are fixed accordingly.

Related issue(s)

Resolves #442 (closed)

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

    • I checked whether I should update the docs and did so if necessary:
    • I updated changelog files of all affected packages released to Hackage if my changes are externally visible.

Stylistic guide (mandatory)

Merge request reports