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

Re: Misleading error message when compiling with first-class polymorphism (PR#1365) #3629

Closed
vicuna opened this issue Sep 3, 2002 · 0 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Sep 3, 2002

Original bug ID: 1366
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

From: tim@fungible.com

Put this text into a file and compile it with ocamlc:

class type ['a] eventdesc = object end

type 'a described_event = {ddesc: 'a eventdesc}
[..]
You'll get an error like

File "foo.ml", line 15, characters 38-71:
This method has type 'a described_event which is less general than
'b. 'b described_event

This error message is bad; the problem is actually that the method has
type string described_event.

You got me for almost an hour on that. Before I realized that here,
'a eventdesc is equal to string eventdesc. Why is it so?
Since 'a does not appear in the expension of event desc (< >),
It's binding does not matter.

If the type were simply 'a described_event for all 'a, then the type
would not be less general than the intended type.

Here the problem is more subtle. Due to the value restriction,
eventdesctable has a monomorphic type, and as a result all type
variables appearing in it cannot be generalized. This is what this
message says: 'a is not a generalizable variable. Maybe printing it as
'_a would be more intuitive.

And yes, this is slightly in contradiction with the above explanation:
if 'a does not matter, why can't we generalize it? Well, these unused
variables are a pain anyway. They are only useful if you want to make
an abstract type out of eventdesc, and you will not get a coherent
behaviour otherwise. Actually your program might be accepted in future
versions.

 Jacques
@vicuna vicuna closed this as completed Sep 3, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant