Skip to content
Snippets Groups Projects

Proto/Michelson: fix `PAIR k` annots

Merged Tom Jack requested to merge tomjack/tezos:fix-pairk-annots into master

Context

The PAIR k instruction currently converts @ annotations on the stack to % annotations. For example, PAIR 2 works like PAIR %@ %@.

This causes troubles with typing, for example, this typechecks:

{ parameter unit;
  storage unit;
  code { SENDER @foo; SOURCE @bar; PAIR 2;
         SOURCE @foo; SENDER @bar; PAIR 2;
         COMPARE; DROP;
         CDR; NIL operation; PAIR } }

but it fails to typecheck if the @foo and @bar annots are removed.

This makes it difficult to use PAIR k in a compiler, because it may cause type errors.

This change fixes the problem by merely removing the behavior. PAIR k will put no % annotations at all on the result.

An alternative could be to allow the user to specify the field annotations (allowing the user to opt in to the current behavior using %@) but this does not seem important.

Checklist

  • For new features and bug fixes, add an item in the appropriate changelog (docs/protocols/alpha.rst for the protocol and the environment, the Development Version section of CHANGES.md for everything else).
  • Select suitable reviewers using the Reviewers field below.
Edited by Tom Jack

Merge request reports

Pipeline #304214007 passed with warnings

Pipeline passed with warnings for 52b1affb on tomjack:fix-pairk-annots

Merged by Marge BotMarge Bot 3 years ago (May 17, 2021 4:43pm UTC)

Loading

Pipeline #304241615 passed

Pipeline passed for 7904a9b2 on master

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • The code looks good to me. My only comments are about the test.

  • assigned to @yrg

  • mentioned in merge request ligolang/ligo!1102 (merged)

  • Mehdi Bouaziz requested review from @mbouaziz

    requested review from @mbouaziz

  • added priorityhigh typebug labels and removed prioritymedium label

  • Raphaël Cauderlier added 308 commits

    added 308 commits

    Compare with previous version

  • I have tested that the proposed script:

    parameter unit;
    storage unit;
    code { SENDER; SOURCE; PAIR 2;
           SOURCE; SENDER; PAIR 2;
           COMPARE; DROP;
           CDR; NIL operation; PAIR }

    is considered ill-typed before this patch and well-tyed after this patch.

  • Raphaël Cauderlier added 167 commits

    added 167 commits

    Compare with previous version

  • added 2 commits

    • 83206880 - Proto/Michelson: fix `PAIR k` annots
    • ab57da72 - add changelog entry

    Compare with previous version

  • Tom Jack added 3 commits

    added 3 commits

    • 018749d1 - Proto/Michelson: fix `PAIR k` annots
    • 92ad0496 - Tests/Michelson: add a non-regression test for annotations in PAIR k
    • e7bcadc8 - add changelog entry

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading