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

Syntax error bug in generated JavaScript #208

Closed
bitc opened this issue Aug 13, 2015 · 2 comments
Closed

Syntax error bug in generated JavaScript #208

bitc opened this issue Aug 13, 2015 · 2 comments
Assignees
Labels

Comments

@bitc
Copy link

bitc commented Aug 13, 2015

When trying to run JSCover on a large JavaScript file I get an error in the browser developer console:

Uncaught SyntaxError: Unexpected token -

Here is the relevant block of code that JSCover generated, note the offending line that tries to create a JavaScript function with the (invalid) name visit8876_-1_1

function visit8878_59_15(result) {
  _$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][15].ranCondition(result);
  return result;
}_$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][14].init(25, 21, '0 < (f = this.data[n] >> u)');
function visit8877_59_14(result) {
  _$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][14].ranCondition(result);
  return result;
}_$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['-1'][1].init(23, 36, 'visit8872_59_10(0 < (f = this.data[n] >> u)) && (k = !0 , l = m(f))');
function visit8876_-1_1(result) {
  _$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['-1'][1].ranCondition(result);
  return result;
}_$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][13].init(14, 8, 'u < this.A');
function visit8875_59_13(result) {
  _$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][13].ranCondition(result);
  return result;
}_$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][12].init(218, 46, 'visit8870_59_8(u < this.A) && visit8871_59_9(visit8872_59_10(0 < (f = this.data[n] >> u)) && (k = !0 , l = m(f)))');
function visit8874_59_12(result) {
  _$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][12].ranCondition(result);
  return result;
}_$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][11].init(204, 1, 'visit8869_59_7(visit8870_59_8(u < this.A) && visit8871_59_9(visit8872_59_10(0 < (f = this.data[n] >> u)) && (k = !0 , l = m(f))))');
function visit8873_59_11(result) {
  _$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][11].ranCondition(result);
  return result;
}_$jscoverage['/particles-ghcjs/_build/all.min.js'].branchData['59'][10].init(228, 21, '0 < (f = this.data[n] >> u)');

If you would like to see this error for yourself, here is a link to the HTML page containing the JavaScript that triggers this bug: https://bitc.github.io/tojs-benchmark/particles-ghcjs/index.min.html?barriers=l5&particles=500

@tntim96
Copy link
Owner

tntim96 commented Aug 15, 2015

You can try the fix from source, the latest drone.io build
or the maven snapshot. For maven you'll need to add sonatype repository with:

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

I can still see errors when instrumenting the compressed JS file, but they don't occur after formatting it with IntelliJ. You might want to try that before re-running to progress further. I think the errors occurring with the compressed source are due to Rhino, and might take some time to resolve.

If you could help isolate the problem with a smaller code example, that would help a lot.

@tntim96
Copy link
Owner

tntim96 commented Aug 16, 2015

I can still see errors when instrumenting the compressed JS file

These should be fixed now too.

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

2 participants