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

Native parser does not allow indentation mismatch at EOF #608

Closed
isidentical opened this issue Jan 17, 2022 · 2 comments · Fixed by #611
Closed

Native parser does not allow indentation mismatch at EOF #608

isidentical opened this issue Jan 17, 2022 · 2 comments · Fixed by #611
Assignees
Labels
bug Something isn't working

Comments

@isidentical
Copy link
Contributor

Short reproducer: (Only happens when the LIBCST_PARSER_TYPE=native)

import ast
import libcst

src = "if bleh:\n  print()\n "
ast.parse(src) # works perfectly
libcst.parse_module(src) # INDENT of 2 space does not match with indent of 1 space
0,0-0,0:            ENCODING       'utf-8'        
1,0-1,2:            NAME           'if'           
1,3-1,7:            NAME           'bleh'         
1,7-1,8:            OP             ':'            
1,8-1,9:            NEWLINE        '\n'           
2,0-2,1:            INDENT         '\t'           
2,1-2,6:            NAME           'print'        
2,6-2,7:            OP             '('            
2,7-2,8:            OP             ')'            
2,8-2,9:            NEWLINE        '\n'           
3,0-3,0:            DEDENT         ''             
3,0-3,0:            ENDMARKER      ''             
@zsol zsol added the bug Something isn't working label Jan 17, 2022
@zsol zsol self-assigned this Jan 17, 2022
@zsol
Copy link
Member

zsol commented Jan 17, 2022

Another way to repro, including the error message:

❯ printf 'if bleh:\n  print()\n ' | cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/parse`
Parse error for stdin: tokenizer error: no matching outer block for dedent

@zsol
Copy link
Member

zsol commented Jan 17, 2022

Seems like this is only a problem at the end of the file. Mixed indents are otherwise completely fine AFAICT.

@zsol zsol changed the title Native parser does not allow indentation mismatch Native parser does not allow indentation mismatch at EOF Jan 17, 2022
@zsol zsol closed this as completed in #611 Jan 18, 2022
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