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
Typing error message is worse that before #6173
Comments
Comment author: furuse I am also confused by this error message. Is it possible to print which type the constructor (here ()) belongs to? Does the new variant name disambiguation thing prevent it? |
Comment author: @garrigue Indeed, the new variant name disambiguation allows using a constructor based on the type, even if this constructor is not the latest one defined, or not even in scope. We could easily list up the types in scope which contain the said constructor. Error: An expression of type 'a list was expected. might be clearer. Note also that if it was just a typo, the error message is often better than before: (Same 3 : int option);;Error: The variant type option has no constructor Same |
Comment author: furuse I prefer the message you proposed. |
Comment author: @johnwhitington It is suggested by doligez in bug #5936 that () as a constructor may be removed soon. This would fix this particular problem. I didn't mean to suggest that the new message is in general a problem, I just think it's awfully confusing to the user when something as fundamental as unit is involved. |
Comment author: @johnwhitington Even more confusing example, where the list constructor :: doesn't even appear explicitly in the source:
This used to be:
which was better, because it mentioned the type 'list'. |
Comment author: @xavierleroy Any hope of addressing johnwhitington's latest example? I'm afraid not given the new type inference strategy introduced to handle constructor disambiguation. |
Comment author: @Octachron I have a naive question. Since the confusing apparition of (::) in the error message stems from special casing [ a ; ..] in the syntax, would it not make sense to also special case (::) in the error message? For instance, by adding a short note: The constructor :: does not belong to type unit. Note: this constructor is used implicitely by the list syntax [ a ; .. ]. |
Comment author: @johnwhitington A long-term solution to these problems might be to decorate the parse tree to indicate where syntactic sugar has been expanded during parsing. If those decorations find their way unharmed through to the typed tree, the we could know the difference between a programmer writing "1::2::3::[]" and "[1; 2; 3]" in the source. Ditto for "fun x y -> x + y" vs "fun x -> fun y -> x + y". This difference would only be relevant when reporting an error, of course, not during typechecking itself. |
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. |
Original bug ID: 6173
Reporter: @johnwhitington
Assigned to: @garrigue
Status: assigned (set by @johnwhitington on 2015-11-23T21:49:16Z)
Resolution: reopened
Priority: normal
Severity: feature
Version: 4.01.0
Target version: later
Fixed in version: 4.02.0+dev
Category: typing
Has duplicate: #6295
Related to: #5936
Child of: #7338
Monitored by: @gasche @hcarty @dbuenzli
Bug description
Is this related to the new variants work? Is it related to the fact that () is, unusually, a valid constructor (this has been debated before, I know)?
The previous behaviour is much less confusing.
The text was updated successfully, but these errors were encountered: