bublejs / bublejs/buble

let/const in try...catch are not block-scoped

Open
#106 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
874
Forks
62
PR merge metrics
No merged PRs in 30d

Description

```javascript
for ( let i = 0; i < 10; i += 1 ) {
try {
const square = i * i;
setTimeout( () => console.log( square ), i * 100 );
} catch (e) {}
}
```
Generates:
```javascript
for ( var i = 0; i < 10; i += 1 ) {
try {
var square = i * i;
setTimeout( function () { return console.log( square ); }, i * 100 );
} catch (e) {}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the JavaScript example and compare it with the generated output, focusing on let/const handling inside try...catch and the loop. Reproduce the transformation, then verify that the generated code preserves block scoping and the per-iteration value used by the delayed callback.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.