LibCST icon indicating copy to clipboard operation
LibCST copied to clipboard

Rust parser: Error with parenthesised annotations

Open AA-Turner opened this issue 1 year ago • 0 comments

The following legal code errors on the Rust parser, but not the Python one:

(n): int = 1
$ python -m libcst.tool print tmp.py
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "...\Lib\site-packages\libcst\tool.py", line 863, in <module>
    main(os.environ.get("LIBCST_TOOL_COMMAND_NAME", "libcst.tool"), sys.argv[1:])
  File "...\Lib\site-packages\libcst\tool.py", line 858, in main
    return lookup.get(args.action or None, _invalid_command)(proc_name, command_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\Lib\site-packages\libcst\tool.py", line 279, in _print_tree_impl
    tree = parse_module(
           ^^^^^^^^^^^^^
  File "...\Lib\site-packages\libcst\_parser\entrypoints.py", line 109, in parse_module
    result = _parse(
             ^^^^^^^
  File "...\Lib\site-packages\libcst\_parser\entrypoints.py", line 55, in _parse
    return parse(source_str)
           ^^^^^^^^^^^^^^^^^
libcst._exceptions.ParserSyntaxError: Syntax Error @ 1:1.
parser error: error at 1:5: expected one of !=, %, &, (, *, **, +, ,, -, ., /, //, ;, <, <<, <=, =, ==, >, >=, >>, @, NEWLINE, [, ^, and, if, in, is, not, or, |

(n): int = 1
^

LibCST version 1.0.1; Python 3.11.5; Windows

A

AA-Turner avatar Sep 05 '23 20:09 AA-Turner