Skip to content

Conversation

@shulhi
Copy link
Member

@shulhi shulhi commented Nov 24, 2025

Fix #8013

This PR improves the formatter's handling of underscore placeholders (_) in pipe expressions by automatically converting them to their canonical form. When a placeholder appears in the first position of a piped function call and it's the only placeholder occurrence, the formatter now omits it since the pipe operator already provides that argument.

Examples:

  • a->map2(_, fn) → formats to a->map2(fn)
  • filterNone->Array.get(_, 0) → formats to filterNone->Array.get(0)

The formatter preserves multiple placeholders when they're semantically meaningful (e.g., a->f(_, _, b) remains unchanged).

@shulhi shulhi force-pushed the fix-pipe-underscore-printing branch 2 times, most recently from c759df6 to d13942e Compare November 28, 2025 13:28
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 28, 2025

Open in StackBlitz

rescript

npm i https://pkg.pr.new/rescript-lang/rescript@8033

@rescript/darwin-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-arm64@8033

@rescript/darwin-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/darwin-x64@8033

@rescript/linux-arm64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-arm64@8033

@rescript/linux-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/linux-x64@8033

@rescript/runtime

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/runtime@8033

@rescript/win32-x64

npm i https://pkg.pr.new/rescript-lang/rescript/@rescript/win32-x64@8033

commit: 871436a

@shulhi shulhi force-pushed the fix-pipe-underscore-printing branch from d13942e to 65ac40c Compare December 24, 2025 12:51
@shulhi shulhi marked this pull request as ready for review December 24, 2025 13:02
@shulhi shulhi requested review from cknitt and nojaf December 25, 2025 12:27
Copy link
Member

@nojaf nojaf left a comment

Choose a reason for hiding this comment

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

Looks good, don't forget your changelog entry.

@cknitt
Copy link
Member

cknitt commented Dec 26, 2025

@shulhi Thanks! Cann you add a CHANGELOG entry and maybe add a comment to address @nojaf's concern?

As for release management, I think this one is fine to go into 12.0.2 (current master) as a fix for weird formatting after migration.
I would however like to revert #7993 first (and reapply it after we have moved to 12.1 on master).

@shulhi shulhi enabled auto-merge (squash) December 26, 2025 08:10
@shulhi shulhi merged commit 5782b77 into rescript-lang:master Dec 26, 2025
24 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.

Deprecated decorator w/ let and pipes

3 participants