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
tag-spec-full documentation seems to be incorrect #5926
Comments
Comment author: @lpw25 I think that the documentation should probably be something like: tag-spec-full ::= `tag-name [ of [ typexpr ] { & typexpr } ] A "correct" (although non-sensical) example would be: type 'a z = [< `c of int & float] as 'a;; I'm not sure, but I think that some of your examples may actually be failing because of a bug in the type-checker. The type [< |
Comment author: @bobzhang leo, thanks! I am exploiting some sophisticated usage of polymorphic variants. It would be nice the detailed behavior is documented |
Comment author: @garrigue I've fixed the grammar in the manual. |
Comment author: @bobzhang I can make a working example now type 'a z = [< `c of int & int ] as 'a;;type 'a z = 'a constraint 'a = [< `c of int ] let u : 'a z = `c 3 ;;val u : [ But I do not get a working example for 'of &' directly Did I miss something? thanks, type 'a v = [< `c ] as 'a;;type 'a v = 'a constraint 'a = [< `c ] type 'a z = [< `c of & 'a v ] as 'a ;;Characters 12-36: |
Comment author: @garrigue I'm not sure what you are trying to do. |
Comment author: @bobzhang garrigue, I found some bugs in camlp4 when handling polymorphic variants, so I want to make sure that I understand every corner case of variants before I try to fix it. |
Original bug ID: 5926
Reporter: @bobzhang
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:18:31Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.01.0+dev
Category: documentation
Bug description
tag-spec-full is documented as follows:
tag-spec-full ::= `tag-name [ of typexpr ] { & typexpr }
It seems that `tag-name {& expr} will result in a syntax error.
Is there any documentation explaining how conjuctive types work?
I did not get a working example yet.
Thanks
type 'a z = [< `c & u2] as 'a;;
Error: Syntax error
type 'a z = [< `c of & u2] as 'a;;
Error: Type declarations do not match:
type 'a z = 'a constraint 'a = [<
c of & u2 ] is not included in type 'a z = 'a constraint 'a = [<
c of & u2 ]type 'a u3 = [<
b |
a of & int & bool & int ] as 'a;;Error: Type declarations do not match:
type 'a u3 = 'a constraint 'a = [<
a of & int & bool |
b ]is not included in
type 'a u3 = 'a constraint 'a = [<
a of & int & bool |
b ]type 'a u3 = [<
b |
a of & int & int ] as 'a;;Error: Type declarations do not match:
type 'a u3 = 'a constraint 'a = [<
a of & int |
b ]is not included in
type 'a u3 = 'a constraint 'a = [<
a of & int |
b ]The text was updated successfully, but these errors were encountered: