Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Do not instrument Identifier when preceded by typeof #33

Merged
merged 1 commit into from

2 participants

@floriancargoet

When an identifier isn't declared, it's valid to use it in one specific expression:

 typeof foo; // 'undefined'

Since it's instrumented by node-cover, it fails.

cover run test.js
ReferenceError: foo is not defined

This pull request remove the instrumentation of identifiers when their parent node is a typeof operator.

@floriancargoet

Any comment on that PR, @itay ?

@itay
Owner

Looks great, sorry for delay!

@itay itay merged commit e746849 into from
@floriancargoet floriancargoet deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 instrument.js
View
5 instrument.js
@@ -388,6 +388,11 @@ Instrumentor.prototype.wrap = function(tree, ignoredLines) {
parent.type == 'DoWhileStatement'))) {
return;
}
+ // Do not instrument Identifier when preceded by typeof
+ if (parent.operator == 'typeof') {
+ return;
+ }
+
}
var newNode = {
"type": "SequenceExpression",
Something went wrong with that request. Please try again.