Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser Idempotency: Generator drops indentation on nested def #4825

Closed
Tracked by #4972
addisoncrump opened this issue Jun 3, 2023 · 0 comments · Fixed by #4875
Closed
Tracked by #4972

Parser Idempotency: Generator drops indentation on nested def #4825

addisoncrump opened this issue Jun 3, 2023 · 0 comments · Fixed by #4875
Assignees
Labels
bug Something isn't working

Comments

@addisoncrump
Copy link
Contributor

addisoncrump commented Jun 3, 2023

The following source code is incorrectly round-tripped by ruff_python_ast::source_code::round_trip:

def d():
    def e():
        pass

The result is:

def d():

    
def e():
        pass

Which is invalid syntax.

This error does not seem to persist to the Ruff command line. The cause appears to be that newlines are explicitly invoked for def and some other types, but the indent is not applied afterward. This appears to affect all types of def in unparse_stmt, so I'm not quite sure how this isn't propagating to frontend.

Discovered by #4822

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants