From e2d97cbaf9f6213a8d6a031252ec1dd1b7fdfd08 Mon Sep 17 00:00:00 2001 From: Martin Kuntz Jacobsen Date: Mon, 9 Nov 2026 17:33:00 +0100 Subject: [PATCH] quality: fix compile_check on ocaml -w warning specs (closes #10148) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Xut2hwESun1HL2eSVd1d5B --- quality/compile_check.bzl | 7 ++++++- quality/compile_check_tests.bzl | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/quality/compile_check.bzl b/quality/compile_check.bzl index be4a9c5867..740d91738e 100644 --- a/quality/compile_check.bzl +++ b/quality/compile_check.bzl @@ -137,6 +137,8 @@ def ghc_check_argv(argv, scratch): _OCAML_DROP = ["-bin-annot", "-annot", "-c"] +_OCAML_VALUE_FLAGS = ["-w", "-warn-error"] + _OCAML_FLAGS = ["-stop-after", "typing", "-error-style", "short", "-color", "never"] def _basename(path): @@ -156,7 +158,10 @@ def ocaml_check_argv(argv, scratch): output = "" compiles = 0 take = "" + previous = "" for arg in argv[1:]: + value_of = previous + previous = arg if take != "": if take == "-o": output = arg @@ -166,7 +171,7 @@ def ocaml_check_argv(argv, scratch): intf = arg take = "" continue - if arg.startswith("@"): + if arg.startswith("@") and value_of not in _OCAML_VALUE_FLAGS: return _fail("params files are not supported (found " + arg + ")") if arg in ["-o", "-impl", "-intf"]: take = arg diff --git a/quality/compile_check_tests.bzl b/quality/compile_check_tests.bzl index 189cadabb6..973beccbb6 100644 --- a/quality/compile_check_tests.bzl +++ b/quality/compile_check_tests.bzl @@ -143,6 +143,11 @@ def compile_check_unit_tests(name): ocaml_check_argv([_OCAMLC, "@a.params", "-c", "-impl", "p/m.ml", "-o", "out/M.cmo"], "tmp").error != "", True, ), + expect_equal( + "ocaml warning specs starting with @ are flag values", + ocaml_check_argv([_OCAMLC, "-w", "@1..3@5..28", "-warn-error", "@8", "-c", "-impl", "p/m.ml", "-o", "out/M.cmo"], "tmp").error, + "", + ), expect_equal( "ocaml without -c is rejected", ocaml_check_argv([_OCAMLC, "-impl", "p/m.ml", "-o", "out/M.cmo"], "tmp").error != "",