Skip to content

[Chore] Attach source code location to interpreter error messages

Nikolay Yakimov requested to merge lierdakil/tm155-interpreter-fail-src-pos into master

Description

Problem: We have the similar mechanism for typechecker errors, however, it also makes sense to report a precise source position for FAILWITH and other instructions which can fail in the interpreter. We already have the source location information in the AST during interpretation. All that's left is threading that through and attaching it to MichelsonFailed errors when needed.

Solution:

  • add 'InstrCallStack' field to 'ContractEnv' (for the purpose of threading the source location around through Reader)
  • add 'MichelsonFailureWithStack', a product of 'MichelsonFailed' and 'InstrCallStack'; use it as interpreter error instead of plain 'MichelsonFailed'
  • add 'Buildable' instances for 'InstrCallStack' and 'MichelsonFailureWithStack'
  • make the necessary changes to keep the compiler happy
  • add a test

Related issue(s)

Resolves TM-155

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 Nikolay Yakimov

Merge request reports