babel / babel/babel

[Bug]: Returned value of a generator function becomes enumerable

Open
#15,152 1 comment 0 reactions 0 assignees View on GitHub
i: needs triage
Dominant language
TypeScript
Stars
44k
Forks
6k
Avg merge
5d 15h
Merged PRs (30d)
23

Description

### 💻

- [ ] Would you like to work on a fix?

### How are you using Babel?

Other (Next.js, Gatsby, vue-cli, ...)

### Input code

```js
function * f(){}

var x = f();
for(p in x) console.log(p);
```

### Configuration file name

_No response_

### Configuration

_No response_

### Current and expected behavior

`input.js` prints nothing:
```console
$ node input.js # prints nothing
```
```console
$ node output.js
next
throw
return
toString
```

### Environment

[Reproduction on Babel's own REPL](https://babeljs.io/repl#?browsers=since%202015&build=&builtIns=false&corejs=3.21&spec=false&loose=false&code_lz=PTAEGcAsHsFcBsAmoAOAnAlgOwC6i9DpNgOYA0oARrHgPrYBu0A1gKagAUAhlsoZKzTgAlKky5WiAFAAzWFgDGODNCygAVKBkdhAbwC-UqQy5pQAD1ABeLToDcs6Gg4pQ2C6IWrw0eKwB08NAkLsJ2QA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=script&lineWrap=true&presets=env%2Creact%2Cstage-2&prettier=true&targets=&version=7.20.2&externalPlugins=&assumptions=%7B%7D)

### Possible solution

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the example from input.js and compare Node's output with output.js generated through the Babel REPL using the shown presets. Trace the generator transformation entry point and its tests; done means the transformed generator's returned value does not expose enumerable properties during for-in iteration, matching native behavior.

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.