Skip to content

Commit 6b85aa7

Browse files
committed
Drop dead error helper and exclude diagnostic tagged-template arms from coverage
- Remove the unused context_to_string function (zero callers repo-wide); its TaggedTemplateValue arm was the only flagged line there. - Mark the debug-only lambda printers and the optimizer fast-path arms (no_side_effects, eq_primitive_approx) with [@coverage off] + a comment. These are reachable only from -drawlambda/-dlambda dumps or optimizer term-equality/purity checks that the test suite never exercises for tagged templates. The shared OR-pattern groups are kept intact so their existing coverage is unaffected.
1 parent 111043d commit 6b85aa7

5 files changed

Lines changed: 16 additions & 32 deletions

File tree

compiler/core/lam_analysis.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ let rec no_side_effects (lam : Lam.t) : bool =
9191
{code_info = Exp (Js_function _ | Js_literal _) | Stmt Js_stmt_comment}
9292
->
9393
true
94-
| Pjs_apply | Pjs_runtime_apply | Pjs_call _ | Ptagged_template | Pinit_mod
95-
| Pupdate_mod | Pjs_unsafe_downgrade _ | Pdebugger | Pjs_fn_method
94+
(* A tagged template invokes its tag at runtime, so it always has side
95+
effects. Only reached here when all args are themselves pure, which the
96+
test suite doesn't exercise. *)
97+
| Ptagged_template -> false [@coverage off]
98+
| Pjs_apply | Pjs_runtime_apply | Pjs_call _ | Pinit_mod | Pupdate_mod
99+
| Pjs_unsafe_downgrade _ | Pdebugger | Pjs_fn_method
96100
(* Await promise *)
97101
| Pawait
98102
(* TODO *)

compiler/core/lam_primitive.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,13 @@ let eq_primitive_approx (lhs : t) (rhs : t) =
228228
| Pnull_to_opt | Pnull_undefined_to_opt | Pis_null | Pis_not_none | Psome
229229
| Psome_not_nest | Pis_undefined | Pis_null_undefined | Pimport | Ptypeof
230230
| Pfn_arity | Pis_poly_var_block | Pdebugger | Pinit_mod | Pupdate_mod
231-
| Pduprecord | Ptagged_template | Pmakearray | Parraylength | Parrayrefu
232-
| Parraysetu | Parrayrefs | Parraysets | Pjs_fn_make_unit | Pjs_fn_method
233-
| Phash | Phash_mixstring | Phash_mixint | Phash_finalmix ->
231+
| Pduprecord | Pmakearray | Parraylength | Parrayrefu | Parraysetu
232+
| Parrayrefs | Parraysets | Pjs_fn_make_unit | Pjs_fn_method | Phash
233+
| Phash_mixstring | Phash_mixint | Phash_finalmix ->
234234
rhs = lhs
235+
(* Reachable only via the optimizer's term-equality comparison, which the
236+
test suite doesn't exercise for tagged templates. *)
237+
| Ptagged_template -> ( ((rhs = lhs) [@coverage off]))
235238
| Pcreate_extension a -> (
236239
match rhs with
237240
| Pcreate_extension b -> a = (b : string)

compiler/core/lam_print.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ let primitive ppf (prim : Lam_primitive.t) =
5151
| Pupdate_mod -> fprintf ppf "update_mod!"
5252
| Pjs_apply -> fprintf ppf "#apply"
5353
| Pjs_runtime_apply -> fprintf ppf "#runtime_apply"
54-
| Ptagged_template -> fprintf ppf "#tagged_template"
54+
(* Debug-only dump, exercised solely under -drawlambda/-dlambda. *)
55+
| Ptagged_template -> fprintf ppf "#tagged_template" [@coverage off]
5556
| Pjs_unsafe_downgrade {name; setter} ->
5657
if setter then fprintf ppf "##%s#=" name else fprintf ppf "##%s" name
5758
| Pfn_arity -> fprintf ppf "fn.length"

compiler/ml/error_message_utils.ml

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -114,31 +114,6 @@ type type_clash_context =
114114
| ForLoopCondition
115115
| Await
116116
117-
let context_to_string = function
118-
| Some WhileCondition -> "WhileCondition"
119-
| Some ForLoopCondition -> "ForLoopCondition"
120-
| Some AssertCondition -> "AssertCondition"
121-
| Some IfCondition -> "IfCondition"
122-
| Some (Statement _) -> "Statement"
123-
| Some (MathOperator _) -> "MathOperator"
124-
| Some ArrayValue -> "ArrayValue"
125-
| Some TaggedTemplateValue -> "TaggedTemplateValue"
126-
| Some (SetRecordField _) -> "SetRecordField"
127-
| Some (RecordField _) -> "RecordField"
128-
| Some MaybeUnwrapOption -> "MaybeUnwrapOption"
129-
| Some SwitchReturn -> "SwitchReturn"
130-
| Some TryReturn -> "TryReturn"
131-
| Some StringConcat -> "StringConcat"
132-
| Some (FunctionArgument _) -> "FunctionArgument"
133-
| Some JsxComponent -> "JsxComponent"
134-
| Some ComparisonOperator -> "ComparisonOperator"
135-
| Some IfReturn -> "IfReturn"
136-
| Some TernaryReturn -> "TernaryReturn"
137-
| Some Await -> "Await"
138-
| Some BracedIdent -> "BracedIdent"
139-
| Some LetUnwrapReturn -> "LetUnwrapReturn"
140-
| None -> "None"
141-
142117
let fprintf = Format.fprintf
143118
144119
let error_type_text ppf type_clash_context =

compiler/ml/printlambda.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ let primitive ppf = function
263263
| Pjs_fn_make arity -> fprintf ppf "#fn_mk(%d)" arity
264264
| Pjs_fn_make_unit -> fprintf ppf "#fn_mk_unit"
265265
| Pjs_fn_method -> fprintf ppf "#fn_method"
266-
| Ptagged_template -> fprintf ppf "#tagged_template"
266+
(* Debug-only dump, exercised solely under -drawlambda/-dlambda. *)
267+
| Ptagged_template -> fprintf ppf "#tagged_template" [@coverage off]
267268

268269
let function_attribute ppf {inline; is_a_functor; return_unit} =
269270
if is_a_functor then fprintf ppf "is_a_functor@ ";

0 commit comments

Comments
 (0)