Skip to content

Interference between the object system and inlining annotations #12232

@lthls

Description

@lthls

Example code:

module type E = sig end
module A(E:E) = struct end [@@inline] (* No objects *)
module C(E:E) = struct class c = object end end [@@inline]
module O(E:E) = struct let o = object end end [@@inline]

Compiling with ocamlopt -c -w +53 test.ml gives the following output:

File "test.ml", line 3, characters 0-58:
3 | module C(E:E) = struct class c = object end end [@@inline]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 53 [misplaced-attribute]: the "inline" attribute cannot appear in this context
File "test.ml", line 4, characters 0-56:
4 | module O(E:E) = struct let o = object end end [@@inline]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 53 [misplaced-attribute]: the "inline" attribute cannot appear in this context

This shows that for the C and O functors, the [@@inline] attribute isn't correctly moved to the functor.

Initially reported by @talex5 at https://discuss.ocaml.org/t/capnproto-functor-inlining/12111/9

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions