Skip to content

Bug: Generator in method call fails with augmented assignment (+=) #35

@swernerx

Description

@swernerx

Description

Generator expressions passed directly to method calls like .join() are not being converted to proper JavaScript syntax.

Python Input

result = fieldsep.join(repr(name) for name in names)
total = sum(x * 2 for x in values)
any_null = any(item is None for item in items)

Current Output (v1.3.3)

let result = fieldsep.join(repr(name) for name in names)  // ❌ INVALID!
let total = sum(x * 2 for x in values)  // ❌ INVALID!
let any_null = any(item is None for item in items)  // ❌ INVALID!

Expected Output

const result = fieldsep.join(names.map(name => repr(name)))
const total = sum(values.map(x => x * 2))
const any_null = any(items.map(item => item === null))

Or with IIFE generators (consistent with standalone generators):

const result = fieldsep.join((function*() { for (const name of names) yield repr(name) })())

Note

Standalone generator expressions ARE correctly converted to IIFE generators:

gen = (x for x in items)  # Works! → (function*() { ... })()

But when passed directly to a method call, they're not converted.

Affected Files

Found ~124 occurrences in NumPy migration.

Priority

🔴 Critical - Causes ~400 errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions