jashkenas/coffeescript

Bug: Chained comparison doesn't work with `in` binary operator

STRd6 opened this issue · 1 comments

STRd6 commented

in is a relational operator and should work with chained comparisons.

Input Code

a in b in d

Expected Behavior

var ref,
  indexOf = [].indexOf;

indexOf.call(b, a) >= 0 && indexOf.call(d, b) >= 0;

Current Behavior

var ref,
  indexOf = [].indexOf;

ref = indexOf.call(b, a) >= 0, indexOf.call(d, ref) >= 0;

Python Behavior

daniel@DESKTOP-HATA8GU:~/apps/civet$ python3
Python 3.8.10 (default, Jun 22 2022, 20:18:18) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 1
>>> b = [1]
>>> a in b
True
>>> c = [b]
>>> b in c
True
>>> a in b in c
True
>>> 
  • CoffeeScript version: 2.7.0

@GeoffreyBooth Feel encouraged to bundle up these "breaking changes" bug reports into a Coffee3 tag/milestone... a man can dream 🌟

Feel encouraged to bundle up these “breaking changes” bug reports into a Coffee3 tag/milestone… a man can dream 🌟

Based on the tempo of PRs lately I think it’s clear that the project is in maintenance mode. Unless there’s a groundswell of volunteering energy like there was for CoffeeScript 2, I don’t see a CoffeeScript 3 anytime soon (if ever).

That said, bugs are bugs, and fixing them shouldn’t be considered breaking changes as long as the “fix” isn’t drastic (like it shouldn’t break CoffeeScript’s own codebase, at minimum). But I’m skeptical of bugfixes for the sake of lexical consistency. CoffeeScript is a real language used by real people on real projects, not an academic computer science project, and some inconsistency is acceptable when the alternative is breaking people for no good reason besides “correctness.”