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

GM 4 Scripts Error: expected expression, got ')' #2670

Closed
erosman opened this Issue Nov 15, 2017 · 10 comments

Comments

Projects
None yet
3 participants
@erosman

erosman commented Nov 15, 2017

Hi

Working scripts under GM 3 fail under GM 4

Could not execute user script: [Greasemonkey Script .../....; 1.0] 
 Error: expected expression, got ')'
Stack trace:
Async*@moz-extension://ffbb8d40-70fc-42b4-9d63-f5ac882801f8/src/bg/execute.js:23:5
  execute.js:29:7

Any idea what the cause is?

Note: There is no JS error in the code. (tested)

After testing .... it seem the following fails

// ==UserScript==
// @name          Clean URL
// @namespace     erosman
// @description   Clean URLs
// @include       *
// @grant         none
// @author        erosman
// @version       1.0
// ==/UserScript==


(function() { 


})(); // end of anonymous function

Fix: adding an extra line or removing the end comment eliminates the error.

The following works fine .... (added a blank line)

// ==UserScript==
// @name          Clean URL
// @namespace     erosman
// @description   Clean URLs
// @include       *
// @grant         none
// @author        erosman
// @version       1.0
// ==/UserScript==
*/

(function() { 


})(); // end of anonymous function

Following works as well ... (removed the end comment)

// ==UserScript==
// @name          Clean URL
// @namespace     erosman
// @description   Clean URLs
// @include       *
// @grant         none
// @author        erosman
// @version       1.0
// ==/UserScript==
*/

(function() { 


})();

@erosman erosman changed the title from All Scripts Error: expected expression, got ')' to GM 4 All Scripts Error: expected expression, got ')' Nov 15, 2017

@erosman erosman changed the title from GM 4 All Scripts Error: expected expression, got ')' to GM 4 Scripts Error: expected expression, got ')' Nov 15, 2017

@Sxderp

This comment has been minimized.

Show comment
Hide comment
@Sxderp

Sxderp Nov 15, 2017

Contributor

The way the parsing works is to create a function for the userscript and then call it. The current implementation defines the script on a single line. If the userscript ends in a comment than it causes the function definition to be invalid.

Contributor

Sxderp commented Nov 15, 2017

The way the parsing works is to create a function for the userscript and then call it. The current implementation defines the script on a single line. If the userscript ends in a comment than it causes the function definition to be invalid.

@Sxderp

This comment has been minimized.

Show comment
Hide comment
@Sxderp

Sxderp Nov 15, 2017

Contributor

Submitted a pull to resolve the issue.

Contributor

Sxderp commented Nov 15, 2017

Submitted a pull to resolve the issue.

@arantius arantius added this to the 4.1 milestone Nov 15, 2017

@arantius

This comment has been minimized.

Show comment
Hide comment
@arantius

arantius Nov 15, 2017

Collaborator

Short term workaround: edit your scripts so they don't have a // line comment on the last line.

Will be fixed in next release.

Collaborator

arantius commented Nov 15, 2017

Short term workaround: edit your scripts so they don't have a // line comment on the last line.

Will be fixed in next release.

@erosman

This comment has been minimized.

Show comment
Hide comment
@erosman

erosman Nov 15, 2017

Short term workaround: edit your scripts so they don't have a // line comment on the last line.

Obviously as pointed out in my initial post, I had already worked that out. ;)

erosman commented Nov 15, 2017

Short term workaround: edit your scripts so they don't have a // line comment on the last line.

Obviously as pointed out in my initial post, I had already worked that out. ;)

@arantius

This comment has been minimized.

Show comment
Hide comment
@arantius

arantius Nov 15, 2017

Collaborator

Sorry you edited that in after your first post, so I didn't see it (read the message as delivered to my email).

Collaborator

arantius commented Nov 15, 2017

Sorry you edited that in after your first post, so I didn't see it (read the message as delivered to my email).

@erosman

This comment has been minimized.

Show comment
Hide comment
@erosman

erosman Nov 15, 2017

Sorry you edited that in after your first post, so I didn't see it (read the message as delivered to my email).

Strange... since the edited post contains the data about it having a comment at the end. The original first post didn't have that information and only listed the error without showing the code.

erosman commented Nov 15, 2017

Sorry you edited that in after your first post, so I didn't see it (read the message as delivered to my email).

Strange... since the edited post contains the data about it having a comment at the end. The original first post didn't have that information and only listed the error without showing the code.

@arantius

This comment has been minimized.

Show comment
Hide comment
@arantius

arantius Nov 15, 2017

Collaborator

Todo me (or @Sxderp ?) add a unit test to ensure this issue doesn't regress in the future.

Collaborator

arantius commented Nov 15, 2017

Todo me (or @Sxderp ?) add a unit test to ensure this issue doesn't regress in the future.

@Sxderp

This comment has been minimized.

Show comment
Hide comment
@Sxderp

Sxderp Nov 15, 2017

Contributor

Ah yes. I'll get on that. Submit as new pull request? If you want it in the same that'll be delaying the fix for a bit, unless you do it. Not sure when I can get around to the test cases[1].

[1] node and friends not setup

Contributor

Sxderp commented Nov 15, 2017

Ah yes. I'll get on that. Submit as new pull request? If you want it in the same that'll be delaying the fix for a bit, unless you do it. Not sure when I can get around to the test cases[1].

[1] node and friends not setup

@arantius

This comment has been minimized.

Show comment
Hide comment
@arantius

arantius Nov 15, 2017

Collaborator

Base pull is already merged.

Collaborator

arantius commented Nov 15, 2017

Base pull is already merged.

@Sxderp

This comment has been minimized.

Show comment
Hide comment
@Sxderp

Sxderp Nov 16, 2017

Contributor

Added pull for tests

Contributor

Sxderp commented Nov 16, 2017

Added pull for tests

@arantius arantius closed this Nov 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment