rust-simplicity icon indicating copy to clipboard operation
rust-simplicity copied to clipboard

Human encoding: Comments collide with names

Open uncomputable opened this issue 1 year ago • 2 comments

In the human encoding, comments start with --. Meanwhile, - is allowed in names, making -- a valid name.

This leads to weird errors like "Error: 1: 1: name -- is referred to but does not exist" in the following program.

main := --

Users might also expect the following program to compile, but it doesn't.

-- := unit
main := --

It seems the best option to make the syntax of comments and names distinct from each other. How does Haskell handle this?

uncomputable avatar Dec 14 '23 14:12 uncomputable

It looks like the actual bug is that if -- ends a line with nothing following it, it is parsed as a name rather than as a comment signifier.

But yes, we should document that -- is not a valid name.

apoelstra avatar Dec 14 '23 14:12 apoelstra

We should add -- to the list of reserved symbols that are not NAMEs.

Edit: Actually any string that matches .*\-\-.* should not be a NAME.

uncomputable avatar Dec 14 '23 15:12 uncomputable