Skip to content

CST node validation is broken for parenthesized MatchAs objects #625

Description

@isidentical

Simple reproducer:

match x:
    case (1) as z:
        pass
thread '<unnamed>' panicked at 'conversion failed for MatchValue: PyErr { type: <class 'libcst._nodes.base.CSTValidationError'>, value: CSTValidationError('Cannot have left paren without right paren.'), traceback: Some(<traceback object at 0x7f533bb89340>) }', libcst/src/nodes/statement.rs:2338:35
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/home/isidentical/projects/LibCST/libcst/tool.py", line 839, in <module>
    main(os.environ.get("LIBCST_TOOL_COMMAND_NAME", "libcst.tool"), sys.argv[1:])
  File "/home/isidentical/projects/LibCST/libcst/tool.py", line 834, in main
    return lookup.get(args.action or None, _invalid_command)(proc_name, command_args)
  File "/home/isidentical/projects/LibCST/libcst/tool.py", line 278, in _print_tree_impl
    tree = parse_module(
  File "/home/isidentical/projects/LibCST/libcst/_parser/entrypoints.py", line 109, in parse_module
    result = _parse(
  File "/home/isidentical/projects/LibCST/libcst/_parser/entrypoints.py", line 55, in _parse
    return parse(source_str)
pyo3_runtime.PanicException: conversion failed for MatchValue: PyErr { type: <class 'libcst._nodes.base.CSTValidationError'>, value: CSTValidationError('Cannot have left paren without right paren.'), traceback: Some(<traceback object at 0x7f533bb89340>) }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions