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

Numbers prefixed with a plus shouldn't throw errors #72

Open
Alhadis opened this issue Aug 5, 2018 · 2 comments
Open

Numbers prefixed with a plus shouldn't throw errors #72

Alhadis opened this issue Aug 5, 2018 · 2 comments

Comments

@Alhadis
Copy link

Alhadis commented Aug 5, 2018

+1 is valid in both CoffeeScript and JavaScript, but cson-parser treats it as an error:

λ ~: echo '+2' | cson2json
/usr/local/lib/node_modules/cson/esnext/cli.js:72
      throw result;
      ^

SyntaxError: Syntax error on line 1, column 1: Unknown unary operator +
    at Op (/usr/local/lib/node_modules/cson/node_modules/cson-parser/lib/parse.js:190:17)
    at transformNode (/usr/local/lib/node_modules/cson/node_modules/cson-parser/lib/parse.js:216:12)
    at Block (/usr/local/lib/node_modules/cson/node_modules/cson-parser/lib/parse.js:94:12)
    at transformNode (/usr/local/lib/node_modules/cson/node_modules/cson-parser/lib/parse.js:216:12)
    at Object.parse (/usr/local/lib/node_modules/cson/node_modules/cson-parser/lib/parse.js:222:16)
@jkrems
Copy link
Contributor

jkrems commented Aug 7, 2018

Hm, interesting. Is there a specific use case for using unary plus in a config? I'd be fine with adding it but I don't think it'd be something we would get around to soon.

@Alhadis
Copy link
Author

Alhadis commented Aug 7, 2018

Probably only for cosmetic affairs like alignment and consistency with other numerals:

 a: +2,
 b: -3,
 3: +3,

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

2 participants