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

Accept value declarations as structure items #6688

vicuna opened this Issue Dec 3, 2014 · 1 comment


None yet
2 participants
Copy link

commented Dec 3, 2014

Original bug ID: 6688
Reporter: @alainfrisch
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2016-12-07T10:37:05Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Related to: #6681 #6698 #6703
Monitored by: @gasche @yallop @hcarty

Bug description

I propose to let the parser accept value declarations (val x : ...) as valid syntactic structure items. They can already be encoded in the Parsetree (as Pstr_primitive, which takes a value_description argument), so the impact on the code (Ast_helper, Ast_mapper, print_ast, etc) is minimal.

Such declarations would be rejected by the type-checker, but later, one could give interesting meaning to them (e.g. to specify locally the expected type scheme for a value definition; or even support local forward declarations). The reason to add them now is to give more freedom to what can go into an extension/attribute payload, cf #6681.

(It would also make sense to rename Pstr_primitive to Pstr_value, but then this impacts more existing code.)

A patch is attached. In addition to it, one should get rid of the following comment in parsetree.mli:

"Note: when used under Pstr_primitive, prim cannot be empty"

File attachments


This comment has been minimized.

Copy link
Collaborator Author

commented Dec 10, 2014

Comment author: @alainfrisch

A similar patch has been pushed to trunk (it relies on a "in_signature" flag stored in typing environments).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.