Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human encoding: Comments collide with names #185

Open
uncomputable opened this issue Dec 14, 2023 · 2 comments
Open

Human encoding: Comments collide with names #185

uncomputable opened this issue Dec 14, 2023 · 2 comments

Comments

@uncomputable
Copy link
Collaborator

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?

@apoelstra
Copy link
Collaborator

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.

@uncomputable
Copy link
Collaborator Author

uncomputable commented Dec 14, 2023

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants