LibCST
LibCST copied to clipboard
Improve ParserSyntaxError messages for parse_expression and parse_statement
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
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