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

Confusing error message when parentheses are added around an expression #7148

Closed
vicuna opened this issue Feb 13, 2016 · 5 comments
Closed

Comments

@vicuna
Copy link

vicuna commented Feb 13, 2016

Original bug ID: 7148
Reporter: @dbuenzli
Status: acknowledged (set by @damiendoligez on 2017-04-13T11:21:39Z)
Resolution: open
Priority: normal
Severity: minor
Version: 4.02.3
Target version: later
Category: lexing and parsing
Child of: #5068
Monitored by: @diml @hcarty

Bug description

I find the following quite confusing

 ocaml
        OCaml version 4.02.3                                                                                                                                    
# f bla:i;;
Error: Syntax error
# (f bla:i);;
Error: Unbound type constructor i

The error came up while forgetting to add the ~ to a labelled argument.

@vicuna
Copy link
Author

vicuna commented Feb 24, 2017

Comment author: @damiendoligez

I'm not sure I understand what's confusing about these errors and what we could do to get better messages.

@vicuna
Copy link
Author

vicuna commented Feb 24, 2017

Comment author: @dbuenzli

What the author wants to write here is ... (f ~bla:i) .... The reported error being so far away from the initial aim, it just doesn't make the programmer think about the right way to fix it and leaves him head scratching.

Much better error messages can be given in this case by suggesting in a "Did you mean" fashion that this could be either a type constraint or a misspelled labelled application. This can be achieved by reasoning on the current type and value identifiers in scope. E.g. if i is in the value scope and not in the type scope and bla is not in the value scope it seems more likely to be a labelled application that is missing a ~.

@dbuenzli
Copy link
Contributor

I suspect I'm speaking nonsense here since I doubt the actual information I'm mentioning is available when the error occurs. Maybe this should be closed.

@gasche
Copy link
Member

gasche commented Mar 16, 2019

I agree that the solution you propose looks a bit too sophisticated, but I'll leave the issue open as a valuable example of "plausible mistake that needs better ergonomics".

@github-actions
Copy link

github-actions bot commented May 9, 2020

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

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

No branches or pull requests

3 participants