Drop Nil arguments from Run actions in generated lock directories
Follow-up to #15090. That issue covered too tracks; Track A, the Slang.simplify fold, landed in #15092 and auto-closed it. This issue tracks the remaining Track B.
(when false "") is how Slang.encode serializes Nil, since Nil has no surface syntax. In the portable lock directory for the relocatable compiler, the build action's agument list is full of (when false "") entries. These are the visible symptom from #14457.
Each of those arguments already simplifies to Nil, so the remaining noise comes from where the Run arguments are assembled in src/dune_pkg/lock_pkg.ml:
- An opam command argument with an always-false filter is built as
Slang.when_ <false-filter> argand simplified toNilaroundlock_pkg.ml:346–348. - That
Nilis kept in theAction.Runterm list. Thefilter_mapreturnsSome (… Nil)with no check forNilaroundlock_pkg.ml:326, and the terms are passed straight toAction.Runatlock_pkg.ml:353. - When the lock directory is written,
Slang.encode Nilserializes it back into(when false "").
Fix: drop Nil terms where the Run arguments are assembled, or have Run use Slang.simplify.
Caveat: per @Alizter in #14457, Run may not currently usee Slang.simplify due to a perceived package breakage at the time, so this change need care
Verification plan:
- Run
test/blackbox-tests/test-cases/pkgand promote the expected updates. - Build a package such as
ocaml-rewithdune pkgand confirm the generated lock-directory entries still behave correctly after simplification.
@Alizter I have started drafting a plan to wrap up this final piece of the issue.
Opened #15128 for this. It drops the Nil args in lock_pkg.ml, along with a regression test. Verified end-to-end against the relocatable compiler (the exact case from #14457): the lock directory now has no (when false "") entries, all real arguments are preserved, and it still builds and runs.