biome style/noUselessElse
labelled safe
Programs
| id | result | title | hazard |
|---|---|---|---|
| r1-p001 | silent prediction off | Temporal Dead Zone - Else Removal Exposes Premature Access | temporal dead zone |
| r1-p002 | fix ok | __proto__ Key Conflict After Else Lifting | __proto__ keys, prototype access, Object.assign vs spread |
| r1-p003 | fix ok | Async Await Promise Order Changed by Control Flow | async/await, promise ordering, generators and yield position |
| r1-p004 | fix ok | Label Break Interaction With Lifted Else Block | label/break/continue control flow, finally blocks, early returns in nested blocks |
| r1-p005 | fix ok | Sparse Array Hole Preservation Depends On Else Execution | sparse arrays, holes, Array(n) vs [n], array-likes |
| r1-p006 | invalid | Numeric Coercion Side Effect In Else Block Expression | numeric/string coercion: + vs template literal, String(x) vs ${x}, Symbol, BigInt, objects with toString/valueOf |
| r1-p007 | fix ok | Strict Mode This Value Captured By Closure In Else | strict vs sloppy mode semantics (this, octal, duplicate params, with) |
| r1-p008 | fix ok | Exception Thrown In Else Changes Control Flow After Fix | exceptions thrown inside the code the fix removes or rewrites |
Sources
r1-p001 · Temporal Dead Zone - Else Removal Exposes Premature Access
1function f() {
2 if (false) {}
3 else {
4 console.log(a);
5 const a = 1;
6 }
7}
r1-p002 · __proto__ Key Conflict After Else Lifting
1function f(obj) {
2 if (!obj) return;
3 else {
4 obj.__proto__ = null;
5 return obj;
6 }
7}
8console.log(f({a:1})['a']);
--- orig.js 2026-10-17 15:31:08.736251088 -0400 +++ fixed.js 2026-10-17 15:31:09.005265676 -0400 @@ -1,8 +1,7 @@ function f(obj) { if (!obj) return; - else { + obj.__proto__ = null; return obj; - } } console.log(f({a:1})['a']);
1
r1-p003 · Async Await Promise Order Changed by Control Flow
1async function f() {
2 if (true) return await Promise.resolve(1);
3 else {
4 console.log('skipped');
5 return 2;
6 }
7}
8f().then(console.log);
--- orig.js 2026-10-17 15:31:09.153273657 -0400 +++ fixed.js 2026-10-17 15:31:09.416287839 -0400 @@ -1,8 +1,7 @@ async function f() { if (true) return await Promise.resolve(1); - else { + console.log('skipped'); return 2; - } } f().then(console.log);
1
r1-p004 · Label Break Interaction With Lifted Else Block
1outer: {
2 if (false) break outer;
3 else {
4 console.log('else');
5 break outer;
6 }
7}
8console.log('done');
--- orig.js 2026-10-17 15:31:09.584296898 -0400 +++ fixed.js 2026-10-17 15:31:09.844310917 -0400 @@ -1,8 +1,7 @@ outer: { if (false) break outer; - else { + console.log('else'); break outer; - } } console.log('done');
else done
r1-p005 · Sparse Array Hole Preservation Depends On Else Execution
1function f() {
2 if (true) return [,1];
3 else {
4 return [2,];
5 }
6}
7console.log(JSON.stringify(f()));
--- orig.js 2026-10-17 15:31:10.009319812 -0400 +++ fixed.js 2026-10-17 15:31:10.266333589 -0400 @@ -1,7 +1,6 @@ function f() { if (true) return [,1]; - else { + return [2,]; - } } console.log(JSON.stringify(f()));
[null,1]
r1-p006 · Numeric Coercion Side Effect In Else Block Expression (generated program does not parse: /home/sun/dev/diaghunt/runs/2026-10-17T19-31-0)
1let x = { valueOf: () => { console.log('coerced'); return 0; } };
2if (true) return;
3else {
4 console.log(+x);
5}
6console.log('end');
r1-p007 · Strict Mode This Value Captured By Closure In Else
1"use strict";
2function f() {
3 if (true) return;
4 else {
5 return function() { console.log(this); };
6 }
7}
8const g = f();
9g && g();
--- orig.js 2026-10-17 15:31:10.454343668 -0400 +++ fixed.js 2026-10-17 15:31:10.687356158 -0400 @@ -1,9 +1,8 @@ "use strict"; function f() { if (true) return; - else { + return function() { console.log(this); }; - } } const g = f(); g && g();
r1-p008 · Exception Thrown In Else Changes Control Flow After Fix
1function f() {
2 if (true) return;
3 else {
4 throw new Error('trapped');
5 }
6}
7try { f(); } catch(e) { console.log(e.name); }
--- orig.js 2026-10-17 15:31:10.838364253 -0400 +++ fixed.js 2026-10-17 15:31:11.079377148 -0400 @@ -1,7 +1,6 @@ function f() { if (true) return; - else { + throw new Error('trapped'); - } } try { f(); } catch(e) { console.log(e.name); }