WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@cristianoc
Copy link
Collaborator

Optional argument analysis now only considers calls from live code when determining which optional arguments are unused. This prevents false positives when a function is only called from dead code.

Changes:

  • Add pos_from to optional_arg_call to track caller binding position
  • Add is_live predicate to compute_optional_args_state
  • Two-pass solve: first compute deadness, then optional args with liveness
  • Add Decl.isLive helper to simplify repeated liveness checks
  • Update ARCHITECTURE.md to document the two-pass approach

cristianoc added a commit that referenced this pull request Dec 9, 2025
@cristianoc cristianoc requested review from cknitt and zth December 9, 2025 18:35
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 9, 2025

Open in StackBlitz

rescript

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

@rescript/darwin-arm64

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

@rescript/darwin-x64

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

@rescript/linux-arm64

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

@rescript/linux-x64

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

@rescript/runtime

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

@rescript/win32-x64

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

commit: 4637d9e

Copy link
Member

@zth zth left a comment

Choose a reason for hiding this comment

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

Awesome stuff!

@cknitt
Copy link
Member

cknitt commented Dec 10, 2025

Please rebase and move the CHANGELOG entry to 12.0.2.

Optional argument analysis now only considers calls from live code when
determining which optional arguments are unused. This prevents false
positives when a function is only called from dead code.

Changes:
- Add pos_from to optional_arg_call to track caller binding position
- Add is_live predicate to compute_optional_args_state
- Two-pass solve: first compute deadness, then optional args with liveness
- Add Decl.isLive helper to simplify repeated liveness checks
- Update ARCHITECTURE.md to document the two-pass approach

Signed-Off-By: Cristiano Calcagno <[email protected]>
@cristianoc cristianoc force-pushed the reanalyze-liveness-aware-optional-args branch from b71cd1b to 4637d9e Compare December 10, 2025 09:35
Copy link
Member

@cknitt cknitt left a comment

Choose a reason for hiding this comment

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

Thanks! 👍

@cristianoc cristianoc merged commit a1adb9c into master Dec 10, 2025
25 checks passed
@cristianoc cristianoc deleted the reanalyze-liveness-aware-optional-args branch December 10, 2025 11:13
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.

4 participants