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

Attributes on class signatures #6476

Closed
vicuna opened this issue Jul 2, 2014 · 3 comments
Closed

Attributes on class signatures #6476

vicuna opened this issue Jul 2, 2014 · 3 comments
Assignees
Labels
Milestone

Comments

@vicuna
Copy link

vicuna commented Jul 2, 2014

Original bug ID: 6476
Reporter: @lpw25
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:28:09Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.02.0+dev
Fixed in version: 4.02.0+dev
Category: ~DO NOT USE (was: OCaml general)
Tags: patch

Bug description

Currently, attributes and extensions are allowed for class types but not class signatures. For example:

# class type c = object end [@foo];;
Characters 26-28:
  class type c = object end [@foo];;
                            ^^
Error: Syntax error

# class type c = [%foo];;
Characters 15-17:
  class type c = [%foo];;
                 ^^
Error: Syntax error

The attached patch fixes this.

File attachments

@vicuna
Copy link
Author

vicuna commented Jul 3, 2014

Comment author: @alainfrisch

Thanks, well spotted. I've integrated your patch to the 4.02 branch.

Neither the previous version nor the new one supports putting attributes on "arrow" class_types, as in:

module type S = sig class c : (int -> object end) [@foo] end;;

Adding an "LPAREN class_type RPAREN attribute" production to class_type introduces conflicts. This is certainly not critical, but if you have a nice suggestion on how to address that, let me know!

@vicuna
Copy link
Author

vicuna commented Jul 3, 2014

Comment author: @lpw25

Adding an "LPAREN class_type RPAREN attribute" production to class_type introduces conflicts. This is certainly not critical, but if you have a nice suggestion on how to address that, let me know!

I had a look at this when writing the patch, but it seems like it would be very difficult to support parentheses there. Some of the conflicts are easy to fix, but the conflict which appears in code like:

((foo -> bar)) vs. ((foo -> bar) -> baz)

is pretty awkward since foo should reduce to a class argument in the first but not the second, and we can only tell which it is when we see the second closing parenthesis.

@vicuna
Copy link
Author

vicuna commented Jul 4, 2014

Comment author: @alainfrisch

Ok, thanks. I doubt people will really need to use attributes on non-signature class types.

@vicuna vicuna closed this as completed Dec 11, 2015
@vicuna vicuna added this to the 4.02.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
avsm pushed a commit to avsm/ocaml that referenced this issue Jun 21, 2020
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

2 participants