Skip to content

Support scannable axes#135

Merged
julesjacobs merged 3 commits intojanefrom
jujacobs/ocamlformat-scannable-axes
Apr 14, 2026
Merged

Support scannable axes#135
julesjacobs merged 3 commits intojanefrom
jujacobs/ocamlformat-scannable-axes

Conversation

@julesjacobs
Copy link
Copy Markdown

@julesjacobs julesjacobs commented Apr 3, 2026

These now parse and format correctly:

type t : any non_pointer
type t : value non_pointer
type t : value maybe_pointer
type t : value maybe_pointer non_pointer

Qualified abbreviations are supported too:

type t : Foo.bar non_pointer

And scannable modifiers compose correctly with existing kind syntax:

type t : value non_pointer with type_
type t : value non_pointer mod mode

These are preserved rather than rewritten:

type t : Foo.immediate
type t : immediate non_pointer
type t : Foo.immediate64
type t : immediate64 maybe_pointer

Note:

  • The parser now matches OxCaml directly by accepting type_longident as the abbreviation head, rather than narrower
  • The formatter preserves scannable modifiers in source order instead of normalizing them (do we want to normalize?)
  • The immediate / immediate64 rewrite path now only rewrites unqualified & modifier-free abbreviations, to avoid removing scannable-axis components

@julesjacobs julesjacobs force-pushed the jujacobs/ocamlformat-scannable-axes branch from 315d296 to 4944080 Compare April 8, 2026 20:25
@julesjacobs julesjacobs marked this pull request as ready for review April 13, 2026 17:25
@rtjoa rtjoa requested a review from mdelvecchio-jsc April 13, 2026 19:11
Copy link
Copy Markdown

@mdelvecchio-jsc mdelvecchio-jsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a test with comments between the layout and the scannable axes, e.g. type t : value (* hi *) non_pointer. Then should be good.

@julesjacobs
Copy link
Copy Markdown
Author

Thanks Megan! I've added the test

@mdelvecchio-jsc mdelvecchio-jsc self-requested a review April 14, 2026 19:58
@julesjacobs julesjacobs merged commit 55665c0 into jane Apr 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants