Skip to content

Format splices like prefix operators#147

Open
jbachurski wants to merge 1 commit into
janefrom
jbachurski/splices-are-like-prefix-operators
Open

Format splices like prefix operators#147
jbachurski wants to merge 1 commit into
janefrom
jbachurski/splices-are-like-prefix-operators

Conversation

@jbachurski

@jbachurski jbachurski commented Jun 24, 2026

Copy link
Copy Markdown

Until now there were a few bugs with the formatting of splices as prefix operators, corresponding to the tests added in this PR:

  • Composition of splices and prefix operators would drop parentheses, e.g. !($x) -> !$x, which broke AST re-parsing and crashed ocamlformat.
  • Similarly, parentheses around a splice attribute would be dropped.
  • Record overwrite syntax would have redundant parentheses.

In contrast to other prefix operators, splices have no unapplied ( $ ) form, so that doesn't require work.

I figured the easiest way to fix these is to move splices to use the same formatting as prefix operators. It might be cleaner to move Pexp_splice to literally be a case of Pexp_prefix, but that might be unnecessarily complicated.

@jbachurski
jbachurski force-pushed the jbachurski/splices-are-like-prefix-operators branch from f1ebd0c to 8311859 Compare June 24, 2026 11:21
@jbachurski
jbachurski requested a review from dvulakh July 16, 2026 10:14
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.

1 participant