Skip to content

Resolve "Internal error: tried to substitute for mutated var"

Motivation and Context

Related Issue: #1508 (closed).

Description

This MR solves the main bug by keeping the immutability flag when re-constructing functions in the testing framework.

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

Example file

$ cat test_imm.ligo 
type storage is int;

type return is list (operation) * storage

function reset (var s : storage) : storage is {
  s := 0;
} with (s);

function main (const _action : unit; const s : storage) : return is
 ((nil : list (operation)), reset(s));

const test_orig = {
  const (_typed_address, _, _) = Test.originate(main, 42, 0tez);
} with (Unit)

Before

$ ligo run test test_imm.ligo 
An internal error ocurred. Please, contact the developers.
internal error, please report this as a bug: tried to substitute for mutated var File "src/passes/15-self_mini_c/subst.ml", line 317, characters 105-112.

After

$ ligo run test test_imm.ligo 
Everything at the top-level was executed.   
- test_orig exited with value ().

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).

Closes #1508 (closed)

Edited by E. Rivas

Merge request reports

Loading