Skip to content

PPX errors with "Ill-formed list of warnings" after removal of -bs-v flag #8090

@illusionalsagacity

Description

@illusionalsagacity

Thank you for filing! Check list:

  • Is it a bug? Usage questions should often be asked in the forum instead.
  • Concise, focused, friendly issue title & description.
  • A minimal, reproducible example.
  • OS and browser versions, if relevant.
  • Is it already fixed in master? Instructions

Summary

When using rescript-legacy with a PPX, the build fails with "Ill-formed list of warnings" because the PPX file modification timestamps are incorrectly appended to the warning flags.

ReScript Version

Built from master after commit 556545df284b0a4bc01da265608d95c871e06155

Non-Minimal Reproduction

  1. clone the reproduce-bs-v-issue branch here see this pr comment

  2. Run cd tests && pnpm i && pnpm run rescript-legacy build

  3. Build fails with:

FAILED: src/Example.ast
Ill-formed list of warnings

Root Cause

Commit 556545df284b0a4bc01da265608d95c871e06155 ("Remove internal/unused -bs-v flag") removed the -bs-v flag from compiler/bsb/bsb_ninja_rule.ml, but didn't account for the fact that PPX file modification timestamps were being appended to that flag for cache invalidation purposes.

Before the commit (lines 145-152 of bsb_ninja_rule.ml):

Ext_buffer.add_char_string buf ' ' warnings;
Ext_buffer.add_string buf " -bs-v ";
Ext_buffer.add_string buf Bs_version.version;
(match ppx_files with
| [] -> ()
| _ ->
  Ext_list.iter ppx_files (fun x ->
      match string_of_float (Unix.stat x.name).st_mtime with
      | exception _ -> ()
      | st -> Ext_buffer.add_char_string buf ',' st);  (* appended to version string *)

This produced: -w -48 -warn-error A -bs-v 12.0.0,1764737842.41 -ppx ...

After the commit:

Ext_buffer.add_char_string buf ' ' warnings;
(match ppx_files with
| [] -> ()
| _ ->
  Ext_list.iter ppx_files (fun x ->
      match string_of_float (Unix.stat x.name).st_mtime with
      | exception _ -> ()
      | st -> Ext_buffer.add_char_string buf ',' st);  (* now appends to warnings! *)

This produces: -w -48 -warn-error A,1764737842.41 -ppx ...

The A,1764737842.41 is not a valid warning specification, causing the compiler to fail. Removing the mtime from being appended here fixes the issue, but it seems pretty useful for ppx's to have this.

Environment

  • OS: macOS (Darwin 24.6.0)
  • Architecture: arm64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions