Skip to content

Commit

Permalink
fix: container is falsy error with block scoping transform
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Mar 19, 2024
1 parent d58c92a commit 08f64fb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions fixtures/issue-289.js
@@ -0,0 +1,4 @@
for (let f; ; ) {
f = "0";
() => (0 ? 1 : parseInt(f));
}
9 changes: 5 additions & 4 deletions package.json
Expand Up @@ -16,10 +16,11 @@
"test-exclude": "^6.0.0"
},
"devDependencies": {
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/plugin-transform-modules-commonjs": "^7.7.5",
"@babel/register": "^7.7.4",
"@babel/cli": "^7.24.1",
"@babel/core": "^7.24.1",
"@babel/plugin-transform-block-scoping": "^7.24.1",
"@babel/plugin-transform-modules-commonjs": "^7.24.1",
"@babel/register": "^7.23.7",
"chai": "^4.2.0",
"coveralls": "^3.0.9",
"cross-env": "^6.0.3",
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Expand Up @@ -128,6 +128,7 @@ export default declare(api => {
inputSourceMap
})
this.__dv__.enter(path)
path.scope.crawl()
},
exit (path) {
if (!this.__dv__) {
Expand Down
15 changes: 15 additions & 0 deletions test/babel-plugin-istanbul.js
Expand Up @@ -327,5 +327,20 @@ describe('babel-plugin-istanbul', function () {
result.code.should.match(/_path.*\.resolve\)\(_path\)/)
result.code.should.not.match(/_path\.resolve\)\(_path\)/)
})

// regression test for https://github.com/istanbuljs/babel-plugin-istanbul/issues/289
it('should instrument: for (let f; ; ) { ...', function () {
var result = babel.transformFileSync('./fixtures/issue-289.js', {
babelrc: false,
configFile: false,
plugins: [
'@babel/plugin-transform-block-scoping',
[makeVisitor, {
include: ['fixtures/issue-289.js']
}]
]
})
console.log(result)
})
})
})

0 comments on commit 08f64fb

Please sign in to comment.