Fix: check allowed chars in entrypoints
Motivation and Context
Daniel reported a bug in a contract which contained a Tezos.emit "%here ye people of Tezos" ()
. This error did not signal it was an invalid entrypoint annotation, and instead failed without giving information.
Description
This MR adds a check for entrypoints.
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 emit_bad_tag.mligo
let main (_,_ : unit * string ) : operation list * string =
[Tezos.emit "%hello world" 12], "bye"
Before
$ ligo compile contract emit_bad_tag.mligo
An internal error ocurred. Please, contact the developers.
Michelson_v1_printer.unparse.
After
$ ligo compile contract emit_bad_tag.mligo
File "emit_bad_tag.mligo", line 2, characters 3-31:
1 | let main (_,_ : unit * string ) : operation list * string =
2 | [Tezos.emit "%hello world" 12], "bye"
Invalid entrypoint "%hello world". One of the following patterns is expected:
* "%bar" is expected for entrypoint "Bar"
* "%default" when no entrypoint is used.
Valid characters in annotation: ('a' .. 'z' | 'A' .. 'Z' | '_' | '.' | '%' | '@' | '0' .. '9').
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