From a1db56c8e4eef743d844ff90e48ff708b27dcb4d Mon Sep 17 00:00:00 2001 From: CLAUDE <355856132+HoTT-stuff@users.noreply.github.com> Date: Sat, 5 Dec 2026 12:50:18 +0000 Subject: [PATCH 1/2] fix(test): main's OCaml test suite compiles again test/test_jcs.ml, from #865, did not compile, so dune built no test runner. main's 'build' job has been red since #865, and every later regression was hidden behind it. - a top-level 'let open' with no 'in' becomes 'open Affinescript', which is where Jcs lives; - the canonical_inputs list was missing its ';' separators; - 'tests' is now a flat test_case list, as test_main expects. With the runner building again, #865's canonical key order shows up in one older expectation: eval --json now prints {"diagnostics":..,"success":..,"version":1}. Updated. Two failures remain, not fixed here: #862's continued if/match tests assert the grammar from before #863. That needs an owner call. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zo5h4xmXVEeSeQEDvw --- test/test_interp_eval.ml | 2 +- test/test_jcs.ml | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/test/test_interp_eval.ml b/test/test_interp_eval.ml index b4594a98..d145f51d 100644 --- a/test/test_interp_eval.ml +++ b/test/test_interp_eval.ml @@ -390,7 +390,7 @@ let cli_eval_forward_and_mutual () = check "eval: forward reference" "eval" "fwd.affine" [ "3" ]; check "eval: mutual recursion" "eval" "mutual.affine" [ "even" ]; check "eval --json: mutual recursion" "eval --json" "mutual.affine" - [ "even"; {|{"version":1,"diagnostics":[],"success":true}|} ] + [ "even"; {|{"diagnostics":[],"success":true,"version":1}|} ] let tests = [ Alcotest.test_case "self-recursion" `Quick self_recursion; diff --git a/test/test_jcs.ml b/test/test_jcs.ml index 7e921430..8bd01e09 100644 --- a/test/test_jcs.ml +++ b/test/test_jcs.ml @@ -11,7 +11,7 @@ the BMP, number spelling at both ES6 switch points, and control-character escaping. See docs/reference/JSON-AND-YAML.adoc. *) -let open Yojson.Basic +open Affinescript (* U+20AC, U+00E9, U+1F600, U+E000, U+FFFD *) let euro = "\226\130\172" @@ -35,21 +35,21 @@ let canonical_inputs : (string * Yojson.Basic.t * string) list = [ ; ("string", `String (euro ^ "$\015\nA'B\"\\\\\"/")) ] , "{\"literals\":[null,true,false],\"numbers\":[333333333.3333333,1e+30,4.5,0.002,1e-27],\"string\":\"\226\130\172$\\u000f\\nA'B\\\"\\\\\\\\\\\"/\"}" ) - ( "keys sort by UTF-16 code units, not by insertion order" + ; ( "keys sort by UTF-16 code units, not by insertion order" , `Assoc [ ("b", `Int 1); ("a", `Int 2); ("A", `Int 3); ("aa", `Int 4); ("", `Int 5) ] , "{\"\":5,\"A\":3,\"a\":2,\"aa\":4,\"b\":1}" ) - ( "nested objects and non-ASCII keys pass through verbatim" + ; ( "nested objects and non-ASCII keys pass through verbatim" , `Assoc [ ("z", `List [ `Int 1; `Int 2; `Assoc [ ("y", `Null) ] ]) ; (eacute, `Int 1) ; ("e", `Int 2) ] , "{\"e\":2,\"z\":[1,2,{\"y\":null}],\"\195\169\":1}" ) - ( "an astral key precedes U+E000 (the case UTF-8 byte order gets wrong)" + ; ( "an astral key precedes U+E000 (the case UTF-8 byte order gets wrong)" , `Assoc [ ("astral", `Int 1); (emoji, `Int 2); (replacement, `Int 3); (pua, `Int 4) ] , "{\"astral\":1,\"\240\159\152\128\":2,\"\238\128\128\":4,\"\239\191\189\":3}" ) - ( "ES6 number placement: 1e21 vs 1e20, 1e-7 vs 1e-6, subnormals, -0" + ; ( "ES6 number placement: 1e21 vs 1e20, 1e-7 vs 1e-6, subnormals, -0" , `List [ `Int 0 ; `Float (-0.) @@ -64,7 +64,7 @@ let canonical_inputs : (string * Yojson.Basic.t * string) list = [ ; `Float 0.1 ] , "[0,0,1e+21,100000000000000000000,1e-7,0.000001,5e-324,1.7976931348623157e+308,123456789012345680000,-2.5,0.1]" ) - ( "nested reshaping keeps canonical order at every level" + ; ( "nested reshaping keeps canonical order at every level" , `Assoc [ ( "nested", `Assoc @@ -95,9 +95,11 @@ let test_rejected (name, input) () = | Error _ -> () let tests = - [ ( "canonical serialisation", - List.map (fun v -> Alcotest.test_case (let n, _, _ = v in n) `Quick (test_canonical v)) - canonical_inputs ) - ; ( "I-JSON rejections", - List.map (fun v -> Alcotest.test_case (let n, _ = v in n) `Quick (test_rejected v)) rejected ) - ] + List.map + (fun ((name, _, _) as v) -> + Alcotest.test_case ("canonical: " ^ name) `Quick (test_canonical v)) + canonical_inputs + @ List.map + (fun ((name, _) as v) -> + Alcotest.test_case ("rejected: " ^ name) `Quick (test_rejected v)) + rejected From 484290db0e9668cfec5a3262d1e33f1d7258a969 Mon Sep 17 00:00:00 2001 From: CLAUDE <355856132+HoTT-stuff@users.noreply.github.com> Date: Sat, 5 Dec 2026 13:03:45 +0000 Subject: [PATCH 2/2] test: #862's continued-statement tests follow #863's grammar #863 made a statement if/match end at its closing brace, so the #644 shape (if c { .. } then (u, 2), on the next line or the same line) now type-checks. #862, merged after it, still asserted that shape was StatementContinued, and both tests failed once the runner compiled. The diagnostic is still reachable when a statement's head is a parenthesised if/match that is then called: (if c { () } else { () })(3); The two tests now use that shape. A new test pins that the old #644 shapes type-check. SOUNDNESS.adoc stamp advanced to 28d949f; anchors resealed (test_interp_eval.ml changed in the previous commit). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0136P7Zo5h4xmXVEeSeQEDvw --- docs/SOUNDNESS.adoc | 4 ++-- test/test_call_diagnostics.ml | 34 ++++++++++++++++++++++++---------- tools/soundness-anchors.sha256 | 2 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/docs/SOUNDNESS.adoc b/docs/SOUNDNESS.adoc index e8e4c10a..7f57ddb6 100644 --- a/docs/SOUNDNESS.adoc +++ b/docs/SOUNDNESS.adoc @@ -4,8 +4,8 @@ // Freshness stamp — a real main-ancestor commit (survives squash-merge); advance // it (and --reseal) in any change that touches a soundness path. See "Keeping // this honest" and tools/check-soundness-ledger.sh (property 4). -:ground-truth-sha: 220d6f1 -:ground-truth-date: 2026-12-01 +:ground-truth-sha: 28d949f +:ground-truth-date: 2026-12-05 :stamp-verified-by: tools/check-soundness-ledger.sh :toc: macro :toclevels: 2 diff --git a/test/test_call_diagnostics.ml b/test/test_call_diagnostics.ml index 57d010bb..49954197 100644 --- a/test/test_call_diagnostics.ml +++ b/test/test_call_diagnostics.ml @@ -40,30 +40,43 @@ let line_of (e : Typecheck.type_error) = | Typecheck.Located (_, s) -> s.Span.start_pos.line | _ -> Alcotest.failf "error has no location: %s" (Typecheck.format_type_error e) +(* Since #863 a statement `if`/`match` ends at its closing brace, so the #644 + shape (`if c { .. }` then `(u, 2)` on the next line, or the same line) + type-checks. A statement whose head is a parenthesised `if`/`match` that + is then called still reaches [StatementContinued]. *) let continued_if_is_named_and_located () = let e = expect_error - "pub fn f(t: Int) -> (Int, Int) {\n\ - \ let mut u = t;\n\ - \ if u > 0 { u = 1; }\n\ - \ (u, 2)\n\ + "pub fn f(c: Bool) -> Int {\n\ + \ (if c { () } else { () })(3);\n\ + \ 0\n\ }\n" in - Alcotest.(check int) "line of the if" 3 (line_of e); + Alcotest.(check int) "line of the if" 2 (line_of e); match e with | Typecheck.Located (Typecheck.StatementContinued { kind = "if"; _ }, _) -> () | _ -> Alcotest.failf "expected StatementContinued if, got %s" (Typecheck.format_type_error e) let continued_match_is_named_and_located () = let e = expect_error - "pub fn f(t: Int) -> (Int, Int) {\n\ - \ let mut u = t;\n\ - \ match u { 0 => { u = 1; }, _ => {} }\n\ - \ (u, 2)\n\ + "pub fn f(n: Int) -> Int {\n\ + \ (match n { 0 => (), _ => () })(3);\n\ + \ 0\n\ }\n" in - Alcotest.(check int) "line of the match" 3 (line_of e); + Alcotest.(check int) "line of the match" 2 (line_of e); match e with | Typecheck.Located (Typecheck.StatementContinued { kind = "match"; _ }, _) -> () | _ -> Alcotest.failf "expected StatementContinued match, got %s" (Typecheck.format_type_error e) +(* #863: the old #644 shapes are no longer calls. *) +let statement_if_then_tuple_typechecks () = + List.iter (fun src -> + match typecheck src with + | Ok () -> () + | Error e -> Alcotest.failf "#863: a statement if/match ends at its brace: %s" + (Typecheck.format_type_error e)) + [ "pub fn f(t: Int) -> (Int, Int) {\n let mut u = t;\n if u > 0 { u = 1; }\n (u, 2)\n}\n"; + "pub fn f(t: Int) -> (Int, Int) {\n let mut u = t;\n if u > 0 { u = 1; } (u, 2)\n}\n"; + "pub fn f(t: Int) -> (Int, Int) {\n let mut u = t;\n match u { 0 => { u = 1; }, _ => {} }\n (u, 2)\n}\n" ] + (* A value-position `if` that is not Unit was not a continued statement: plain E0104, located, with no `;` advice (CodeRabbit review on #862). *) let value_position_if_keeps_not_a_function () = @@ -127,6 +140,7 @@ let char_to_string_rejects_a_string () = let tests = [ Alcotest.test_case "continued if: named and located" `Quick continued_if_is_named_and_located; + Alcotest.test_case "#863: statement if/match then tuple type-checks" `Quick statement_if_then_tuple_typechecks; Alcotest.test_case "continued match: named and located" `Quick continued_match_is_named_and_located; Alcotest.test_case "the ; remedy type-checks" `Quick the_documented_remedy_typechecks; Alcotest.test_case "value-position if keeps NotAFunction" `Quick value_position_if_keeps_not_a_function; diff --git a/tools/soundness-anchors.sha256 b/tools/soundness-anchors.sha256 index 8d9a6543..0eaa4d89 100644 --- a/tools/soundness-anchors.sha256 +++ b/tools/soundness-anchors.sha256 @@ -3,12 +3,12 @@ # Regenerate: tools/check-soundness-ledger.sh --reseal # Format: . FIXTURE = file hash; TEST = the # test's function-body hash; SUITE = whole-file hash. -02aa1c6d9d1f8f141c1d7c5701ad08986a1536eadd02596a7715f0c2e7c65877 suite:test/test_interp_eval.ml 09f299eaf7e9a0d912db441f346438e31ea7157f6f730ab1b6d78ef6d22a76a1 test:test_801_planted_collision_refused 0d3623cf36a67860106d64bb32d30633978bb426d4ddd77ecc2bf6e48e1b7263 fixture:test/e2e/fixtures/borrow_callee_returned_borrow_uam.affine 20e73d88738c8fd075f81a36803554f92fa4ee53f71e33fa6759eae07c6e70f4 suite:test/test_intrinsic_shadow.ml 2bbd1b989fd0097530eede3e5230258e0e1092271a23ff7dff20cca65c0e612e suite:test/test_wasm_call_resolution.ml 2dfe36a21983a7dfb7ffa1157f7ddec9865a531a92682976b8fd677e4825e78d test:test_801_impl_methods_refused +3cb9faf269f704f02ce9f595affde2ddb73f66dd31964ec294182aa50e46afa7 suite:test/test_interp_eval.ml 45eb0f3aa5f643afbd003248998dd5a046688418647b491e0f2d4bb55fcbd0f2 test:test_wasm_heap_exhaustion_traps 546939eaa3c64c82edd23da0a3ba7f74bcf7378cfe1e426132dd1a9f8fd46050 test:test_801_transitive_public_and_const 5b84a4f71aa65f9aa9383e31c0cb624291c4f9d0de7cca4a0ea6a76fe85aea35 fixture:test/e2e/fixtures/handle_resume_nontail.affine