Unverified Commit 41829385 authored by Sam Poder's avatar Sam Poder Committed by GitHub

Remove dead code from `JsValue::Binary` in `is_truthy` (#94165)

This is another thing flagged by @bgw's Claude:

```
  3. Dead duplicate match arm in is_truthy for StrictEqual (lines 2469–2494)

  ( … StrictEqual, Constant(a), Constant(b)) if a.is_value_type() => Some(a ==
  b),
  ( … StrictEqual, Constant(a), Constant(b)) if a.is_value_type() => { /* 
  same-type check */ }

  Identical pattern + guard. The second arm — the only one that handles
  cross-type equality conservatively — is unreachable. Looks like a half-applied
   fix.
``` 

I've removed the second arm with a double type check. Tests appear to
still pass and I can't think of a case where we'd hit the second arm.
parent 80d1045f
...@@ -2460,25 +2460,6 @@ impl JsValue { ...@@ -2460,25 +2460,6 @@ impl JsValue {
JsValue::Constant(a), JsValue::Constant(a),
JsValue::Constant(b), JsValue::Constant(b),
) if a.is_value_type() => Some(a == b), ) if a.is_value_type() => Some(a == b),
(
PositiveBinaryOperator::StrictEqual,
JsValue::Constant(a),
JsValue::Constant(b),
) if a.is_value_type() => {
let same_type = {
use ConstantValue::*;
matches!(
(a, b),
(Num(_), Num(_))
| (Str(_), Str(_))
| (BigInt(_), BigInt(_))
| (True | False, True | False)
| (Undefined, Undefined)
| (Null, Null)
)
};
if same_type { Some(a == b) } else { None }
}
( (
PositiveBinaryOperator::Equal, PositiveBinaryOperator::Equal,
JsValue::Constant(ConstantValue::Str(a)), JsValue::Constant(ConstantValue::Str(a)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment