Skip to content

[mypyc] Fix C name conflict with conditional nested async funcs - #22330

Merged
JukkaL merged 2 commits into
masterfrom
mypyc-bulkfix-1182-nested-env-names
Oct 30, 2026
Merged

JukkaL merged 2 commits into
masterfrom
mypyc-bulkfix-1182-nested-env-names

Conversation

@JukkaL

@JukkaL JukkaL commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes mypyc/mypyc#1182.

Multiple conditional definitions of a nested async function or generator
with the same name generated invalid C (redefinition errors):

async def f(flag: bool) -> str:
    if flag:
        async def inner() -> str:
            return "a"
    else:
        async def inner() -> str:
            return "b"
    return await inner()

The environment classes of the nested functions had the same name. Now
we make the names unique, similar to the names of callable classes.

JukkaL and others added 2 commits October 30, 2026 14:15
…unctions

Fixes mypyc/mypyc#1182.

Multiple conditional definitions of a nested async function or generator
with the same name generated invalid C (redefinition errors):

```python
async def f(flag: bool) -> str:
    if flag:
        async def inner() -> str:
            return "a"
    else:
        async def inner() -> str:
            return "b"
    return await inner()
```

The environment classes of the nested functions had the same name. Now
we make the names unique, similar to the names of callable classes.
@JukkaL
JukkaL merged commit d8a43fb into master Oct 30, 2026
18 checks passed
@JukkaL
JukkaL deleted the mypyc-bulkfix-1182-nested-env-names branch October 30, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple nested async functions with same name generate invalid C

2 participants