Skip to content

[#471] Add DUP n

Heitor Toledo Lassarote de Paula requested to merge heitor.toledo/#471-dup-n into edo

Description

Problem: A new DUP n has been added with the edo procotol (008)! This MR introduces the new DUP n instruction which, provided a stack with at least n items, duplicates the one-indexed n-th item and pushes it to the top of the stack.

Solution: Implement this new instruction in untyped and typed form, support it in the type-checker, interpreter, packer and unpacker, and Lorentz. Replace various existing usages of DIP DUP ; SWAP with DUP 2 and DIP n DUP ; DUG n with DUP n.

This MR also moves various contracts back to 008, which were causing tests to fail.

Related issue(s)

Resolves #471 (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)

Edited by Heitor Toledo Lassarote de Paula

Merge request reports