rust-simplicity
rust-simplicity copied to clipboard
Human encoding: Comments collide with names
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?
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.
We should add -- to the list of reserved symbols that are not NAMEs.
Edit: Actually any string that matches .*\-\-.* should not be a NAME.