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

Misleading lex error when forgetting to access qualified identifier #3801

Open
colinwahl opened this issue Mar 2, 2020 · 3 comments · May be fixed by #3845
Open

Misleading lex error when forgetting to access qualified identifier #3801

colinwahl opened this issue Mar 2, 2020 · 3 comments · May be fixed by #3845

Comments

@colinwahl
Copy link
Contributor

colinwahl commented Mar 2, 2020

This is a small nit, but the lex error when forgetting to access a qualified identifier seems a bit misleading. I think we could probably make this particular error more specific for the actual cause, which (imo) is likely that the user forgot to finish what they were typing. (For example, today I was looking around my file for strange whitespace characters without realizing I had just forgotten to finish what I was typing!)

For example, in the following code:

bar :: Int
bar = Foo. 

You get the lex error
Illegal whitespace character U+0020

@natefaubion suggested we could have an error that says Whitespace not allowed in qualified identifier or similar.

You get a similar error for when you forget to access an unqualified identifier, such as

bar :: Int
bar = foo.

resulting in
Unexpected or mismatched indentation

(I'm not sure if the second one is as easy to clean up, but I think the first example is relatively straightforward)

Has anyone else had a similar experience, or have a suggestion for a more specific error message?

@hdgarrood
Copy link
Contributor

"Whitespace not allowed in qualified identifer" sounds okay to me, although I wonder if something like "Unexpected whitespace, expected identifier" might be clearer?

@hdgarrood hdgarrood reopened this Mar 5, 2020
@colinwahl
Copy link
Contributor Author

I agree that "Unexpected whitespace, expected identifier" is clearer. Perhaps we should go with that

@igrep
Copy link

igrep commented Oct 26, 2020

I got puzzled with that kind of error too.
I often make a mistake like below due to the habit of a Haskeller:

foreign import data Foo -- missing a kind signature!

foreign import otherFunc :: Foreign -> Foreign

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

Successfully merging a pull request may close this issue.

3 participants