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
Polymorphic references lose an argument #3834
Comments
Comment author: administrator From: tim@fungible.com Simple answer: the bug is in your code.
Compare these two idioms: function
|
Comment author: administrator
I agree, and thank you for saying things that are interesting and true
If I change the only "_" in my example to "`Other", it fails with this File "foo.ml", line 13, characters 17-532: I think it should have unified int with 'a instead of complaining that
to
it does compile, but I thought the type system was supposed to be able -- |
Comment author: administrator followup problem fixed by JG (2002-10-08) |
Comment author: administrator
Thanks.Tim Freeman |
Comment author: administrator From: tim@fungible.com (Tim Freeman)
This is not actually a bug, but just a side-effect of the fact class I personally think that infering type definitions is not a good idea
Well, not with classes: they are known not to be principal. However I followed your advice: unification is now enforced inside
|
Original bug ID: 1411
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Tim Freeman
Version: CVS
OS: linux
Submission from: adsl-64-161-114-6.dsl.snfc21.pacbell.net (64.161.114.6)
If I attempt to compile this file:
module type S = sig
type foo =
[
Trouble of int |
Other]end
module S: S = struct
type foo =
[
Trouble of int |
Other]class type ['a] bozzo =
object ('self)
constraint 'a = [<foo]
method bar: string
end
class ['a] baz (sf: 'a option): ['a] bozzo =
object (self: 'self)
constraint 'a = [<foo]
method bar: string =
match sf with
None -> failwith "ouch"
| Some sf ->
match sf with
`Trouble r -> failwith "ouch"
| _ -> failwith "ouch"
end
end
I get this message:
Signature mismatch:
Modules do not match:
sig
type foo = [
Other |
Trouble of int]class type ['a] bozzo =
object constraint 'a = [< foo] method bar : string end
class ['a] baz :
'a option ->
object constraint 'a = [< foo >
Trouble] method bar : string end end is not included in S Class declarations do not match: class ['a] baz : 'a option -> object constraint 'a = [< foo >
Trouble] method bar : string enddoes not match
class ['a] baz :
'a option -> object constraint 'a = [< foo] method bar : string end
One type parameter has type
[< foo >
Trouble] = [<
Other |Trouble of int >
Trouble]but is expected to have type [< foo] = [<
Other |
Trouble of int]The problem is that the pattern match "
Trouble r" toward the end somehow lost the "r", thus leading to the incorrect conclusion that the type parameter for "baz" has to include "
Trouble" instead of"`Trouble of int".
The text was updated successfully, but these errors were encountered: