Skip to content

Single line match expr fails #175

@SimenLK

Description

@SimenLK

Describe the bug
Tree returns error when placing a match expression on one line.

In a Lit html string template string the whole document failed its highlighting because it failed from a single-line match expr in the template string.

Copied the match expression multi-line test in test/corpus/expr.txt and made in single line, and it produces the error.

To Reproduce
E.g.: Add this to test/corpus/expr.txt

================================================================================
match expression single-line
================================================================================

let test = match x with | Some x -> x | None -> 1

--------------------------------------------------------------------------------

(file
  (declaration_expression
    (function_or_value_defn
      (value_declaration_left
        (identifier_pattern
          (long_identifier_or_op
            (identifier))))
      (match_expression
        (long_identifier_or_op
          (identifier))
        (rules
          (rule
            (identifier_pattern
              (long_identifier_or_op
                (identifier))
              (identifier_pattern
                (long_identifier_or_op
                  (identifier))))
            (long_identifier_or_op
              (identifier)))
          (rule
            (identifier_pattern
              (long_identifier_or_op
                (identifier)))
            (const
              (int))))))))

Expected behavior
This is copied from this one, and we should expect them to be identical(?):

================================================================================
match expression multi-line
================================================================================

let test =
  match x with
  | Some x -> x
  | None -> 1

--------------------------------------------------------------------------------

(file
  (declaration_expression
    (function_or_value_defn
      (value_declaration_left
        (identifier_pattern
          (long_identifier_or_op
            (identifier))))
      (match_expression
        (long_identifier_or_op
          (identifier))
        (rules
          (rule
            (identifier_pattern
              (long_identifier_or_op
                (identifier))
              (identifier_pattern
                (long_identifier_or_op
                  (identifier))))
            (long_identifier_or_op
              (identifier)))
          (rule
            (identifier_pattern
              (long_identifier_or_op
                (identifier)))
            (const
              (int))))))))

But I get

1 failure:

correct / expected / unexpected

  1. match expression single-line:

    (file
      (ERROR
        (value_declaration_left
          (identifier_pattern
      (declaration_expression
        (function_or_value_defn
          (value_declaration_left
            (identifier_pattern
              (long_identifier_or_op
                (identifier))))
          (match_expression
            (long_identifier_or_op
              (identifier))))
        (infix_expression
          (infix_expression
            (infix_expression
              (application_expression
                (application_expression
              (identifier))
            (rules
              (rule
                (identifier_pattern
                  (long_identifier_or_op
                    (identifier))
                  (ERROR)
                  (identifier_pattern
                    (long_identifier_or_op
                      (identifier))))
                (long_identifier_or_op
                  (identifier)))
              (rule
                (identifier_pattern
                  (long_identifier_or_op
                    (identifier)))
                (long_identifier_or_op
                  (identifier)))
              (infix_op)
              (long_identifier_or_op
                (identifier)))
            (infix_op)
            (long_identifier_or_op
              (identifier)))
          (infix_op)
          (const
            (int)))))
                (const
                  (int))))))))

** Environment (please complete the following information):**

OS:

λ nix-info
system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix) 2.31.3, channels(root): "nixos-25.11, nixos-hardware", nixpkgs: /nix/store/2vz0cwchpn66gxx543j8kk0k40ipgfyd-nixos-25.11/nixos

Grammar version: (as in rev?) commit b576ecf
Editor: Neovim v0.11.7
Tree-sitter: 0.25.10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions