LibCST icon indicating copy to clipboard operation
LibCST copied to clipboard

Improve ParserSyntaxError messages for parse_expression and parse_statement

Open zsol opened this issue 4 years ago • 1 comments

Raise more specific errors when a statement is passed in to parse_expression, or multiple statements to parse_statement.

ParserError: Failed to parse expression - found statement tokens 
Caused by 
ParserSyntaxError: [...]

Originally posted by @lapplislazuli in https://github.com/Instagram/LibCST/issues/640#issuecomment-1036257200

zsol avatar Feb 11 '22 14:02 zsol

LibCST would need to try and re-parse the input as a module when there's a syntax error caught by parse_{expression,statement}. We'd need to consider the performance implications too

zsol avatar Feb 11 '22 14:02 zsol