Fix inlined char switches losing their result
Why
When a function with a switch is inlined into a call such as classify('d'), the switch's argument is a constant, so constant folding can replace the switch with the matching case. Lambda did this for int constants but not for char constants, so JavaScript generation folded the switch instead. It took only the body of the matching case. But cases with the same action share one body: case 100 has an empty body and falls through to case 101. So nothing assigned the result.
JavaScript generation now follows the fall-through when it folds a switch: it takes the first body that isn't empty. Lambda also folds a switch on a char constant, as it does for an int.
modifiedJS inlined switch on a char constant
@inlinelet classify = x => switch x { | 'a' => "a" | 98 => "b" | 'c' .. 'e' => "c-e" | 102 | 'g' => "f-g" | _ => "other" } @inlinelet check = (actual, expected) => Console.log((actual, expected)) check(classify('d'), "c-e")
js
Before
After
let actual;console.log([actual, "c-e"]);console.log(["c-e", "c-e"]);
Fixes #9489