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

Coverify incompatibility ("cwise-parser: Computed this is not allowed") #3

Open
rreusser opened this issue May 11, 2015 · 2 comments
Open

Comments

@rreusser
Copy link
Member

@jaspervdg, @mikolalysenko: here's a minimal test case that fails with a coverify transform:

// coverify-test.js:
var cwise = require('cwise');

var dot = cwise({
  args:['array', 'array'],
  pre: function() {
    this.sum = 0;
  },  
  body: function(a,b) {
    this.sum += a * b;
  },  
  post: function() {
    return this.sum;
  }
});

With browserify@10.1.3 and coverify@1.3.2, Run:

$ browserify -t coverify coverify-test.js | node

The transform succeeds, but executing the resulting code fails:

$ browserify -t coverify coverify-test.js |node
COVERAGE "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" [[12,28],[12,28],[0,29],[56,74],[100,104],[100,112],[100,113],[83,117],[147,151],[147,164],[147,165],[127,169],[203,207],[203,211],[196,212],[179,216],[47,218],[41,219],[41,219],[31,220]]
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 2
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 1
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 0
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 19
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 18
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 17
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 16
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 3
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 7
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 11
COVERED "/Users/rreusser/projects/scijs/rreusser/ndarray-ldl-factorization/coverify-test.js" 15

[stdin]:773
      throw new Error("cwise-parser: Computed this is not allowed")
            ^
Error: cwise-parser: Computed this is not allowed
    at visit ([stdin]:773:13)
    at visit ([stdin]:812:17)
    at visit ([stdin]:770:9)
    at visit ([stdin]:816:13)
    at visit ([stdin]:812:17)
    at visit ([stdin]:816:13)
    at visit ([stdin]:812:17)
    at visit ([stdin]:812:17)
    at preprocess ([stdin]:821:5)
    at createCWise ([stdin]:27:17)
@jaspervdg
Copy link
Member

Basically the problem is that coverify sprinkles __coverageWrap all over the pre, body, and post functions (even if you avoid the quoted error you just get another one). Still, there are two parts to this problem: one is that coverify turns this.sum into f(this).sum, which is not allowed (and it is probably not a good idea to relax this requirement here), the second part is that __coverageWrap gets renamed by cwise (essentially "external" calls are not allowed). The latter could perhaps be solved, but I would not be surprised if we then still run into scoping issues. In other words: assuming you do want coverage information of the pre/body/post functions, I'm not quite sure how to go about realizing that (except for using an ad-hoc procedure that basically ensures the functions are not touched by coverify, and then adding it back in manually by passing in a function as scalar). So what kind of solution are you looking for?

@rreusser
Copy link
Member Author

Thanks for the response and sorry to have let the discussion drop. I've been negligent enough to take the inner workings of cwise for granted, but I'm finally sitting down and working through what's going on here, so I'll see if I can figure out what a solution would even mean.

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

No branches or pull requests

2 participants