Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: using "not in" operator in switch works as "in" instead #5480

Open
hendricha opened this issue Dec 3, 2024 · 0 comments
Open

Bug: using "not in" operator in switch works as "in" instead #5480

hendricha opened this issue Dec 3, 2024 · 0 comments

Comments

@hendricha
Copy link

switch
  when thing in arr
    console.log 'this'
  when thing not in arr
    console.log 'that'

Expected Behavior

The above should probably compile to something along the lines of this:

var indexOf = [].indexOf;

switch (false) {
  case indexOf.call(arr, thing) < 0:
    console.log('this');
    break;
  case indexOf.call(arr, thing) >= 0:
    console.log('that');
}

Current Behavior

It however compiles to this:

var indexOf = [].indexOf;

switch (false) {
  case indexOf.call(arr, thing) < 0:
    console.log('this');
    break;
  case indexOf.call(arr, thing) < 0:
    console.log('that');
}

Environment

  • CoffeeScript version: 2.7.0
  • Node.js version: some version of 14 for legacy reasons
    But the thing happens even on the "try coffeescript" page on the website too

Other context

This does not happen in coffee v1 nor in civet with coffee compat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant