Skip to content

Error checking for closure capturing big maps/operation/contract

E. Rivas requested to merge er433/mini-c/fold_map into dev

Motivation and Context

As described in #1080 (closed) and by Didier in #ligo, there are certain cases in which we capture a big map, and this is only reported when we type-check Michelson.

Description

This MR implements one of the proposed solutions by Tom in #1080 (closed): a self pass in mini-c after inlining/uncurrying.

This pass works by checking the type of free expressions on an E_closure.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)

Changelog

Before fix

$ ligo compile expression cameligo "fun (x : operation) -> fun (y : int) -> x"
Error(s) occurred while checking the contract:
At (unshown) location 16, operation type forbidden in parameter, storage and constants

After fix

$ ligo compile expression cameligo "fun (x : operation) -> fun (y : int) -> x"
                                           
Invalid capturing, term captures the type operation.
Hint: Uncurry or use tuples instead of high-order functions.

Checklist:

  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by E. Rivas

Merge request reports

Loading