CoffeeScriptRedux icon indicating copy to clipboard operation
CoffeeScriptRedux copied to clipboard

Switch doesn't work with the ternary operator

Open rstacruz opened this issue 10 years ago • 2 comments

This:

switch (if a then b else c)
  when d
    e()

is expected to become:

switch (a ? b : c) {
  case d:
    e();
    break;
}

but instead gives you:

  • Unknown expression type: IfStatement

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/4150286-switch-doesn-t-work-with-the-ternary-operator?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F33145&utm_medium=issues&utm_source=github).

rstacruz avatar Sep 01 '14 05:09 rstacruz

Just tried on 1.8.0, it generates the ternary as expected, runs fine (after initialization of course) no errors.

On Mon, Sep 1, 2014 at 7:40 AM, Rico Sta. Cruz [email protected] wrote:

This:

switch (if a then b else c) when d e()

is expected to become:

switch (a ? b : c) { case d: e(); break;}

but instead gives you:

  • Unknown expression type: IfStatement

— Reply to this email directly or view it on GitHub https://github.com/michaelficarra/CoffeeScriptRedux/issues/329.

xyrius avatar Sep 01 '14 07:09 xyrius

It fails in coffeescriptredux 2.0.0-beta8.

http://michaelficarra.github.io/CoffeeScriptRedux/#try:switch%20%28if%20a%20then%20b%20else%20c%29%0A%20%20when%20d%0A%20%20%20%20e%28%29

rstacruz avatar Sep 05 '14 04:09 rstacruz