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

Improve error message for polymorphic variant #5874

Closed
vicuna opened this issue Jan 5, 2013 · 5 comments
Closed

Improve error message for polymorphic variant #5874

vicuna opened this issue Jan 5, 2013 · 5 comments

Comments

@vicuna
Copy link

vicuna commented Jan 5, 2013

Original bug ID: 5874
Reporter: @bobzhang
Status: confirmed (set by @damiendoligez on 2013-06-18T14:01:06Z)
Resolution: open
Priority: normal
Severity: feature
Target version: undecided
Category: typing
Monitored by: @gasche

Bug description

Polymorphic variant is really a nice feature, but it's not widely used due to a not very instructive error message (I guess). In most cases, some errors are caused by a typo(the variant name typed wrong, or the arity lost), I think it may not be too hard to give some suggestions instead of a very large error string which may scared the users
Thanks!

File attachments

@vicuna
Copy link
Author

vicuna commented Jan 6, 2013

Comment author: @gasche

Regarding typos, I think we could do something along the following lines: when there is an unification mismatch between two variant types, check the labels that appear in one but not the other with the typo-finding algorith, using the set of labels on the other side as dictionary. Maybe this should be restricted to annotation propagation, deciding to trust the annotation rather than the term.

@vicuna
Copy link
Author

vicuna commented Jan 6, 2013

Comment author: @bobzhang

I agree, the type annotation should help to give a more friendly hint.

And it may be helpful to offer two errors mode, one is abbreviate which provides most useful content, another is verbose mode.

Sometimes the error message I got is like 20 pages long(two module types unification mismatch)..

@vicuna
Copy link
Author

vicuna commented May 10, 2013

Comment author: @bobzhang

In some cases, when type a mis-match type b, the compiler simply dumps the two types. Suppose type a is big, the error message is ridiculously large.
Some simple analysis would help a lot, suppose a is a concrete type while b is a function type, the compiler could emit a more friendly error message(see tmp.ml)

@vicuna
Copy link
Author

vicuna commented May 10, 2013

Comment author: @bobzhang

Other analysis would help
suppose
type a = big_type list
while
type b = big_type array

when type a mis-matches type b,
the compiler only need tell me one is list the other is array instead of dumping the two types

@github-actions
Copy link

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

1 participant