-
Notifications
You must be signed in to change notification settings - Fork 178
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Lint Name
no-fallthrough
Code Snippet
function booleanAnd(b1: boolean, b2: boolean) {
switch (b1) {
case true: // false positive lint here
switch (b2) {
case true:
default:
return true;
}
case false:
switch (b2) {
case true:
return true;
case false:
return false;
}
}
}
Expected Result
No linting errors.
Actual Result
❯ deno lint foo.ts
error[no-fallthrough]: Fallthrough is not allowed
--> /home/xubaiw/foo.ts:3:5
|
3 | case true:
| ^^^^^^^^^^
|
4 | switch (b2) {
| ^^^^^^^^^^^^^^^^^^^
|
5 | case true:
| ^^^^^^^^^^^^^^^^^^
|
6 | default:
| ^^^^^^^^^^^^^^^^
|
7 | return true;
| ^^^^^^^^^^^^^^^^^^^^^^
|
8 | }
| ^^^^^^^
= hint: Add `break` or comment `/* falls through */` to your case statement
docs: https://docs.deno.com/lint/rules/no-fallthrough
Found 1 problem
Checked 1 file
Additional Info
This issue is different from #1331 , which is involved with End::Break
, while this issue is about End::Continue
.
Also reported in denoland/deno#29805 (closed now).
This problem may arise from here:
deno_lint/src/control_flow/mod.rs
Lines 480 to 488 in 4a56a49
.filter_map(|case| self.get_end_reason(case.start())) | |
.try_fold( | |
End::Forced { | |
ret: false, | |
throw: false, | |
infinite_loop: false, | |
}, | |
|acc, cur| acc.merge_forced(cur), | |
); |
The fallthrough case is considered End::Continue
, and fail to merge in merge_forced
.
Version
deno 2.3.5 (stable, release, x86_64-unknown-linux-gnu)
v8 13.7.152.6-rusty
typescript 5.8.3
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working