Navigation Menu

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 when accessing a record field that doesn't exist #7093

Closed
vicuna opened this issue Dec 14, 2015 · 1 comment
Closed

Confusing error when accessing a record field that doesn't exist #7093

vicuna opened this issue Dec 14, 2015 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented Dec 14, 2015

Original bug ID: 7093
Reporter: @sliquister
Assigned to: @garrigue
Status: resolved (set by @garrigue on 2017-03-14T08:19:57Z)
Resolution: not a bug
Priority: normal
Severity: minor
Version: 4.02.3
Target version: undecided
Category: typing
Monitored by: @gasche @diml @hcarty

Bug description

When typing this code:

type a = { a : unit }
type b = a
let f (b : b) = b.typo

the compiler gives this error:

File "a.ml", line 3, characters 18-22:
Error: This expression has type b
The field typo does not belong to type a

There are two confusing things here:

  • "This expression has type b" despite the position being the record field
    which is not an expression
  • When the type expressions are longer, it's easy to assume the error is the usual "this
    expression has type b but an expression was expected of type a", and then get confused.

Can't the error simply be:

File "a.ml", line 3, characters 18-22:
Error: The field typo does not belong to type a

? The first part doesn't seem useful to me.

@vicuna
Copy link
Author

vicuna commented Mar 14, 2017

Comment author: @garrigue

I agree that the location may be confusing, but the idea is to locate it on the label (to make clear this is about field acess), while giving also information about the expression itself.
Here the first part is not useful, but in some cases the type of the expression itself may be more complicated.
Maybe there could be a different wording, but not that this error message is already collecting strings from various places...

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

2 participants