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

Warning for common CoffeeScript pitfalls #24

Open
davidbau opened this issue Feb 3, 2014 · 1 comment
Open

Warning for common CoffeeScript pitfalls #24

davidbau opened this issue Feb 3, 2014 · 1 comment

Comments

@davidbau
Copy link
Member

davidbau commented Feb 3, 2014

The big advantage of CoffeeScript - optional parentheses for function invocation - is also a big disadvantage when it comes to allowing ambiguous syntax that does not run the way it reads on the screen.

We should improve the ACE editor coffeescript mode to add warnings in the following situations:

  • Function invocation with an argument that contains an expression that contains a non-parenthesesed operator with lower precedence than "a - b". For example
    "touches a and touches b" which is interpreted as "touches(a and touches(b))" should generate a warning, requiring parentheses.
  • Function invocation with an argument with a leading unary minus or unary plus. "a +b" is interpreted as coffeescript as "a(+b)" - an extra space is required for "a + b". This is the worst thing in CoffeeScript, and should generate a warning when it is being interpreted as unary minus or plus.
  • Nested invocation of functions with more than one argument. "dot random color, random [1..100]" is interpreted as "dot(random(color, random([1..100])))". This ambiguity is hard to read and we should require our users to use some parentheses around the inner calls.
@davidbau
Copy link
Member Author

davidbau commented Feb 5, 2014

See the discussion at https://groups.google.com/forum/#!topic/coffeescript/yUPsELGPCQo - there are several other syntax traps noted there.

Also, they point out CoffeeLint: https://github.com/clutchski/coffeelint - a good approach to investigate would be to integrate CoffeeLint into the ACE coffeescript mode (to provide warnings) and then add what we need to CoffeeLint.

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