Skip to content

Strange behavior with backticked javascript comments #1473

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

Closed
Acorn-zz opened this issue Jun 28, 2011 · 4 comments
Closed

Strange behavior with backticked javascript comments #1473

Acorn-zz opened this issue Jun 28, 2011 · 4 comments
Labels

Comments

@Acorn-zz
Copy link

`// ==UserScript==
// @version       1.0
// ==/UserScript==`

alert "hello world"

Gives

// ==UserScript==
// @version       1.0
// ==/UserScript==;alert("hello world");

`// ==UserScript==
// @version       1.0
// ==/UserScript==
`

alert "hello world"

Gives

// ==UserScript==
// @version       1.0
// ==/UserScript==
;alert("hello world");

(With an extraneous semicolon)

@breckinloggins
Copy link
Contributor

This happens because inline JS is treated by the compiler as a Literal. The compiler doesn't know what's inside the JavaScript literal so it just assumes it's executable code (which it normally is).

To fix this, you'd have to parse the JavaScript itself, which would be a challenge and really only useful to solve this specific edge case.

@michaelficarra
Copy link
Collaborator

This looks like it should be a wontfix to me.

@satyr
Copy link
Collaborator

satyr commented Jul 30, 2011

At least, literal → statement compilation is wrong.

$ coffee -bpe '0; 1; 2 if 3; 4; 5'
0;
1;if (3) {
  2;
}
4;
5;

There should be a newline after 1;.

@vendethiel
Copy link
Collaborator

Seems to be fixed, probably our @makeCode.

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

5 participants