Skip to content

[TM-267]: Fix bad error messages in let-block

Moremi Vannak requested to merge rinn7e/tm-267-bad-error-messages into master

Description

Problem: Bad error message in let-block

For example, if we have this in let-block:

let {
  type Store = (BigMap Address Nat, Nat);

  
  test :: '[option int] -> '[int]
  = { IF_SOME { nop } { PUSH int 3 }; };
  #             ^^^
  # Adding `nop` here will cause an error

};

Expected error message:

morley: ../../contracts/FA1/custom.mtz:10:16:
   |
10 |   = { IF_SOME {nop} { PUSH int 3 }; };
   |                ^
unexpected 'n'

Actual error message:

morley: ../../contracts/FA1/custom.mtz:9:3:
  |
9 |   test :: '[option int] -> '[int]
  |   ^
unexpected 't'
expecting '}'

This is due to backtracing issues.

Solution: Fixed by narrowing down the try backtracing.

Related issue(s)

Resolves TM-267

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)

Merge request reports