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

Odd behaviour with certain property assignments #71

Open
Alhadis opened this issue Jul 29, 2018 · 3 comments
Open

Odd behaviour with certain property assignments #71

Alhadis opened this issue Jul 29, 2018 · 3 comments
Labels

Comments

@Alhadis
Copy link

Alhadis commented Jul 29, 2018

Parsing this:

{foo: 2; @bar: 3} # CSON

... quite literally results in "this":

{a: 2, this: 3} // JS

It's also possible to use equals signs for assignment within curly braces, even though CSON docs state that variable assignments aren't allowed in CSON data:

{foo: 2; bar = 1 } # CSON
{foo: 2, bar: 1} // JS

I know cson-parser uses coffee---------script for lexing/parsing, so it's no surprise that some vestiges of its old class syntax are still hanging around. Even so, these constructs should ideally be considered invalid by the parser.

@jkrems jkrems added the bug label Jul 30, 2018
@jkrems
Copy link
Contributor

jkrems commented Jul 30, 2018

Nice find! Thanks for reporting this. Agreed - neither of those should be allowed. I assume it should be possible to exclude them by looking more closely at the AST nodes.

@Alhadis
Copy link
Author

Alhadis commented Aug 1, 2018

Another oddity I've encountered: the following (presumably legal) syntax coughs up an error:

[### aaaa ### a: 2, 
Block: "comment"
]

CSON parser:

[stdin]:1:16: error: unexpected :
[### aaaa ### a: 2,
               ^

However, running the CSON snippet above in a CoffeeScript REPL shows what I expected to see:

[{/* aaaa */ a: 2, Block: "comment"}];

I'm still trying to work out how CoffeeScript handles overly-long # comments like this:

#########
Commented?
### End-of-comment?

The sample above yields puzzling errors from both CoffeeScript and cson-parser:

CoffeeScript REPL:

#########
Commented?
### End-of-comment?

cson-parser:

[stdin]:3:1: error: unexpected #
### End-of-comment?
^

@Inve1951
Copy link

Inve1951 commented Mar 5, 2019

Only an exact amount of 3 # open/close a block comment - everything else is a single-line comment.

Just wanted to drop this heads-up: CS is currently undergoing heavy changes in regards to AST generation: coffeescript/ast

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

No branches or pull requests

3 participants