Skip to content

Comparison operator negation rules can be incorrect #902

@alangpierce

Description

@alangpierce

decaffeinate is producing the wrong JavaScript based on my CoffeeScript input:

unless NaN > 1
  console.log 'first'
else
  console.log 'second'

(repl)

I get this output:

if (NaN <= 1) {
  console.log('first');
} else {
  console.log('second');
}

Here's what I expect it to be instead:

if (!(NaN > 1)) {
  console.log('first');
} else {
  console.log('second');
}

This is causing at least two problems in atom. I think this negation behavior probably needs to be behind a --loose flag, since it doesn't work for operands like NaN and undefined.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions