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
@required scripts without final semicolon cause problems #1491
Comments
You can use GitHub Gist to create an example UserScript. |
Gisted here: https://gist.github.com/1558869 |
Can't reproduce. https://gist.github.com/1677686 Installs and runs both requires, none of the 3 files have a semicolon in them. So it's not just semicolons. It's something else about the contents of those two URLs, as the link you posted (on the 4th) definitely does exhibit some weird behavior. Except your description isn't perfectly correct. There's not "no effect". I see, in the error console:
I also see everything work correctly when I remove the anonymous function wrapper. So: the real cause is that the statement that jquery-ui runs has a return value. The first non-whitespace non-comment character in your script is an open parenthesis, which javascript interprets in this context as a function call to the return value of the still-open statement (semicolon insertion logic fail!). Since it should be universally safe to append semicolons to working requires, I think we'll just do that, to address this class of failure. |
FYI: http://inimino.org/~inimino/blog/javascript_semicolons
(Emphasis mine.) So, in this particular case, where there was only whitespace then an open paren, this is valid syntax, so the semicolon is not inserted. But it's not a valid value to be calling as a function, so the result is a runtime error. |
Reporters: Please test and report whether this build fixes your issues: |
Confirmed that 0.9.15 fixes the issue. I do wonder why I didn't get any errors in my console though. |
Greasemonkey 0.9.13 on Firefox 8.0.1.
Speculation:
It appears that @required scripts that do not end in a semicolon can cause problems in the user script.
Steps to reproduce:
(function(){alert("Hello")})();
Expected result:
Actual result:
Workaound:
Conclusion:
While not hard to work around, the problem is hard to identify, as it produces no errors or obvious side effects (besides the user script doing nothing).
The text was updated successfully, but these errors were encountered: