`SLICE` instruction in testing framework's interpreter
Motivation and Context
We have a discrepancy between testing framework's interpretation of Bytes.sub
/String.sub
and that of Michelson's interpreter.
It can be witnessed with this example:
$ ligo compile expression cameligo "Bytes.sub 5n 0n (0xf0f9c27422 : bytes)"
An error occurred while evaluating an expression: "SLICE"
$ cat test.mligo
let test = Bytes.sub 5n 0n (0xf0f9c27422 : bytes)
$ ligo run test test.mligo
Everything at the top-level was executed.
- test exited with value 0x.
Also, for String.sub
, we have:
$ cat test.mligo
let test = String.sub 5n 10n "hola"
$ ligo run test test.mligo
An internal error ocurred. Please, contact the developers.
(Invalid_argument "pos + len past end: 5 + 10 > 4").
We should not reveal this kind of error.
Description
This MR fixes the issue by guarding sub
in the interpreter with the correct checks.
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
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). -
Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by E. Rivas