Wilfred / difftastic

a structural diff that understands syntax 🟥🟩

Home Page:https://difftastic.wilfred.me.uk/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bad error recovery from (incorrect) C preprocessor error

arbrauns opened this issue · comments

The following file, which is parsed incorrectly by tree-sitter-c due to tree-sitter/tree-sitter-c#108:

static void foo(void) {
#if FOREVER
  while (1) {
#endif
  foo();
#if FOREVER
  }
#endif
}

static void bar(void) {
  if (1) {
    var = (func(a, a.b) + a.b.c);
  } else {
    var = func(a, a.b) + a.b + a.b.c + a.b.c + a.b.c;
  }
}

Produces these --dump-ts/--dump-syntax outputs:

difft dump output
translation_unit (0, 0) - (17, 0)
  ERROR (0, 0) - (16, 1)
    storage_class_specifier (0, 0) - (0, 6)
      static (0, 0) - (0, 6) "static"
    primitive_type (0, 7) - (0, 11) "void"
    function_declarator (0, 12) - (0, 21)
      identifier (0, 12) - (0, 15) "foo"
      parameter_list (0, 15) - (0, 21)
        ( (0, 15) - (0, 16) "("
        parameter_declaration (0, 16) - (0, 20)
          primitive_type (0, 16) - (0, 20) "void"
        ) (0, 20) - (0, 21) ")"
    { (0, 22) - (0, 23) "{"
    #if (1, 0) - (1, 3) "#if"
    identifier (1, 4) - (1, 11) "FOREVER"
    \n (1, 11) - (2, 0) "\n"
    while_statement (2, 2) - (8, 1)
      while (2, 2) - (2, 7) "while"
      parenthesized_expression (2, 8) - (2, 11)
        ( (2, 8) - (2, 9) "("
        number_literal (2, 9) - (2, 10) "1"
        ) (2, 10) - (2, 11) ")"
      compound_statement (2, 12) - (8, 1)
        { (2, 12) - (2, 13) "{"
        preproc_call (3, 0) - (4, 0)
          preproc_directive (3, 0) - (3, 6) "#endif"
        expression_statement (4, 2) - (4, 8)
          call_expression (4, 2) - (4, 7)
            identifier (4, 2) - (4, 5) "foo"
            argument_list (4, 5) - (4, 7)
              ( (4, 5) - (4, 6) "("
              ) (4, 6) - (4, 7) ")"
          ; (4, 7) - (4, 8) ";"
        preproc_if (5, 0) - (7, 6)
          #if (5, 0) - (5, 3) "#if"
          identifier (5, 4) - (5, 11) "FOREVER"
          \n (5, 11) - (6, 0) "\n"
          ERROR (6, 2) - (6, 3)
            } (6, 2) - (6, 3) "}"
          #endif (7, 0) - (7, 6) "#endif"
        } (8, 0) - (8, 1) "}"
    function_definition (10, 0) - (16, 1)
      storage_class_specifier (10, 0) - (10, 6)
        static (10, 0) - (10, 6) "static"
      primitive_type (10, 7) - (10, 11) "void"
      function_declarator (10, 12) - (10, 21)
        identifier (10, 12) - (10, 15) "bar"
        parameter_list (10, 15) - (10, 21)
          ( (10, 15) - (10, 16) "("
          parameter_declaration (10, 16) - (10, 20)
            primitive_type (10, 16) - (10, 20) "void"
          ) (10, 20) - (10, 21) ")"
      compound_statement (10, 22) - (16, 1)
        { (10, 22) - (10, 23) "{"
        if_statement (11, 2) - (15, 3)
          if (11, 2) - (11, 4) "if"
          parenthesized_expression (11, 5) - (11, 8)
            ( (11, 5) - (11, 6) "("
            number_literal (11, 6) - (11, 7) "1"
            ) (11, 7) - (11, 8) ")"
          compound_statement (11, 9) - (13, 3)
            { (11, 9) - (11, 10) "{"
            expression_statement (12, 4) - (12, 33)
              assignment_expression (12, 4) - (12, 32)
                identifier (12, 4) - (12, 7) "var"
                = (12, 8) - (12, 9) "="
                parenthesized_expression (12, 10) - (12, 32)
                  ( (12, 10) - (12, 11) "("
                  binary_expression (12, 11) - (12, 31)
                    call_expression (12, 11) - (12, 23)
                      identifier (12, 11) - (12, 15) "func"
                      argument_list (12, 15) - (12, 23)
                        ( (12, 15) - (12, 16) "("
                        identifier (12, 16) - (12, 17) "a"
                        , (12, 17) - (12, 18) ","
                        field_expression (12, 19) - (12, 22)
                          identifier (12, 19) - (12, 20) "a"
                          . (12, 20) - (12, 21) "."
                          field_identifier (12, 21) - (12, 22) "b"
                        ) (12, 22) - (12, 23) ")"
                    + (12, 24) - (12, 25) "+"
                    field_expression (12, 26) - (12, 31)
                      field_expression (12, 26) - (12, 29)
                        identifier (12, 26) - (12, 27) "a"
                        . (12, 27) - (12, 28) "."
                        field_identifier (12, 28) - (12, 29) "b"
                      . (12, 29) - (12, 30) "."
                      field_identifier (12, 30) - (12, 31) "c"
                  ) (12, 31) - (12, 32) ")"
              ; (12, 32) - (12, 33) ";"
            } (13, 2) - (13, 3) "}"
          else_clause (13, 4) - (15, 3)
            else (13, 4) - (13, 8) "else"
            compound_statement (13, 9) - (15, 3)
              { (13, 9) - (13, 10) "{"
              expression_statement (14, 4) - (14, 53)
                assignment_expression (14, 4) - (14, 52)
                  identifier (14, 4) - (14, 7) "var"
                  = (14, 8) - (14, 9) "="
                  binary_expression (14, 10) - (14, 52)
                    binary_expression (14, 10) - (14, 44)
                      binary_expression (14, 10) - (14, 36)
                        binary_expression (14, 10) - (14, 28)
                          call_expression (14, 10) - (14, 22)
                            identifier (14, 10) - (14, 14) "func"
                            argument_list (14, 14) - (14, 22)
                              ( (14, 14) - (14, 15) "("
                              identifier (14, 15) - (14, 16) "a"
                              , (14, 16) - (14, 17) ","
                              field_expression (14, 18) - (14, 21)
                                identifier (14, 18) - (14, 19) "a"
                                . (14, 19) - (14, 20) "."
                                field_identifier (14, 20) - (14, 21) "b"
                              ) (14, 21) - (14, 22) ")"
                          + (14, 23) - (14, 24) "+"
                          field_expression (14, 25) - (14, 28)
                            identifier (14, 25) - (14, 26) "a"
                            . (14, 26) - (14, 27) "."
                            field_identifier (14, 27) - (14, 28) "b"
                        + (14, 29) - (14, 30) "+"
                        field_expression (14, 31) - (14, 36)
                          field_expression (14, 31) - (14, 34)
                            identifier (14, 31) - (14, 32) "a"
                            . (14, 32) - (14, 33) "."
                            field_identifier (14, 33) - (14, 34) "b"
                          . (14, 34) - (14, 35) "."
                          field_identifier (14, 35) - (14, 36) "c"
                      + (14, 37) - (14, 38) "+"
                      field_expression (14, 39) - (14, 44)
                        field_expression (14, 39) - (14, 42)
                          identifier (14, 39) - (14, 40) "a"
                          . (14, 40) - (14, 41) "."
                          field_identifier (14, 41) - (14, 42) "b"
                        . (14, 42) - (14, 43) "."
                        field_identifier (14, 43) - (14, 44) "c"
                    + (14, 45) - (14, 46) "+"
                    field_expression (14, 47) - (14, 52)
                      field_expression (14, 47) - (14, 50)
                        identifier (14, 47) - (14, 48) "a"
                        . (14, 48) - (14, 49) "."
                        field_identifier (14, 49) - (14, 50) "b"
                      . (14, 50) - (14, 51) "."
                      field_identifier (14, 51) - (14, 52) "c"
                ; (14, 52) - (14, 53) ";"
              } (15, 2) - (15, 3) "}"
        } (16, 0) - (16, 1) "}"
[
    Atom id:1 content:1 {
        content: "static void foo(void) {\n#if FOREVER\n  while (1) {\n#endif\n  foo();\n#if FOREVER\n  }\n#endif\n}\n\nstatic void bar(void) {\n  if (1) {\n    var = (func(a, a.b) + a.b.c);\n  } else {\n    var = func(a, a.b) + a.b + a.b.c + a.b.c + a.b.c;\n  }\n}",
        position: "0:0-16:1",
    },
]

The single error node smooshes everything into a single atom, breaking diff.

Simplifying pretty much anything in the example produces a much more usable output without an error node, e.g. removing one of the .c in L15:

static void foo(void) {
#if FOREVER
  while (1) {
#endif
  foo();
#if FOREVER
  }
#endif
}

static void bar(void) {
  if (1) {
    var = (func(a, a.b) + a.b.c);
  } else {
    var = func(a, a.b) + a.b + a.b.c + a.b.c + a.b;
  }
}
difft dump output
translation_unit (0, 0) - (17, 0)
  function_definition (0, 0) - (8, 1)
    storage_class_specifier (0, 0) - (0, 6)
      static (0, 0) - (0, 6) "static"
    primitive_type (0, 7) - (0, 11) "void"
    function_declarator (0, 12) - (0, 21)
      identifier (0, 12) - (0, 15) "foo"
      parameter_list (0, 15) - (0, 21)
        ( (0, 15) - (0, 16) "("
        parameter_declaration (0, 16) - (0, 20)
          primitive_type (0, 16) - (0, 20) "void"
        ) (0, 20) - (0, 21) ")"
    compound_statement (0, 22) - (8, 1)
      { (0, 22) - (0, 23) "{"
      preproc_if (1, 0) - (7, 6)
        #if (1, 0) - (1, 3) "#if"
        identifier (1, 4) - (1, 11) "FOREVER"
        \n (1, 11) - (2, 0) "\n"
        while_statement (2, 2) - (6, 3)
          while (2, 2) - (2, 7) "while"
          parenthesized_expression (2, 8) - (2, 11)
            ( (2, 8) - (2, 9) "("
            number_literal (2, 9) - (2, 10) "1"
            ) (2, 10) - (2, 11) ")"
          compound_statement (2, 12) - (6, 3)
            { (2, 12) - (2, 13) "{"
            preproc_call (3, 0) - (4, 0)
              preproc_directive (3, 0) - (3, 6) "#endif"
            expression_statement (4, 2) - (4, 8)
              call_expression (4, 2) - (4, 7)
                identifier (4, 2) - (4, 5) "foo"
                argument_list (4, 5) - (4, 7)
                  ( (4, 5) - (4, 6) "("
                  ) (4, 6) - (4, 7) ")"
              ; (4, 7) - (4, 8) ";"
            preproc_if (5, 0) - (6, 0)
              #if (5, 0) - (5, 3) "#if"
              identifier (5, 4) - (5, 11) "FOREVER"
              \n (5, 11) - (6, 0) "\n"
              #endif (6, 0) - (6, 0) ""
            } (6, 2) - (6, 3) "}"
        #endif (7, 0) - (7, 6) "#endif"
      } (8, 0) - (8, 1) "}"
  function_definition (10, 0) - (16, 1)
    storage_class_specifier (10, 0) - (10, 6)
      static (10, 0) - (10, 6) "static"
    primitive_type (10, 7) - (10, 11) "void"
    function_declarator (10, 12) - (10, 21)
      identifier (10, 12) - (10, 15) "bar"
      parameter_list (10, 15) - (10, 21)
        ( (10, 15) - (10, 16) "("
        parameter_declaration (10, 16) - (10, 20)
          primitive_type (10, 16) - (10, 20) "void"
        ) (10, 20) - (10, 21) ")"
    compound_statement (10, 22) - (16, 1)
      { (10, 22) - (10, 23) "{"
      if_statement (11, 2) - (15, 3)
        if (11, 2) - (11, 4) "if"
        parenthesized_expression (11, 5) - (11, 8)
          ( (11, 5) - (11, 6) "("
          number_literal (11, 6) - (11, 7) "1"
          ) (11, 7) - (11, 8) ")"
        compound_statement (11, 9) - (13, 3)
          { (11, 9) - (11, 10) "{"
          expression_statement (12, 4) - (12, 33)
            assignment_expression (12, 4) - (12, 32)
              identifier (12, 4) - (12, 7) "var"
              = (12, 8) - (12, 9) "="
              parenthesized_expression (12, 10) - (12, 32)
                ( (12, 10) - (12, 11) "("
                binary_expression (12, 11) - (12, 31)
                  call_expression (12, 11) - (12, 23)
                    identifier (12, 11) - (12, 15) "func"
                    argument_list (12, 15) - (12, 23)
                      ( (12, 15) - (12, 16) "("
                      identifier (12, 16) - (12, 17) "a"
                      , (12, 17) - (12, 18) ","
                      field_expression (12, 19) - (12, 22)
                        identifier (12, 19) - (12, 20) "a"
                        . (12, 20) - (12, 21) "."
                        field_identifier (12, 21) - (12, 22) "b"
                      ) (12, 22) - (12, 23) ")"
                  + (12, 24) - (12, 25) "+"
                  field_expression (12, 26) - (12, 31)
                    field_expression (12, 26) - (12, 29)
                      identifier (12, 26) - (12, 27) "a"
                      . (12, 27) - (12, 28) "."
                      field_identifier (12, 28) - (12, 29) "b"
                    . (12, 29) - (12, 30) "."
                    field_identifier (12, 30) - (12, 31) "c"
                ) (12, 31) - (12, 32) ")"
            ; (12, 32) - (12, 33) ";"
          } (13, 2) - (13, 3) "}"
        else_clause (13, 4) - (15, 3)
          else (13, 4) - (13, 8) "else"
          compound_statement (13, 9) - (15, 3)
            { (13, 9) - (13, 10) "{"
            expression_statement (14, 4) - (14, 51)
              assignment_expression (14, 4) - (14, 50)
                identifier (14, 4) - (14, 7) "var"
                = (14, 8) - (14, 9) "="
                binary_expression (14, 10) - (14, 50)
                  binary_expression (14, 10) - (14, 44)
                    binary_expression (14, 10) - (14, 36)
                      binary_expression (14, 10) - (14, 28)
                        call_expression (14, 10) - (14, 22)
                          identifier (14, 10) - (14, 14) "func"
                          argument_list (14, 14) - (14, 22)
                            ( (14, 14) - (14, 15) "("
                            identifier (14, 15) - (14, 16) "a"
                            , (14, 16) - (14, 17) ","
                            field_expression (14, 18) - (14, 21)
                              identifier (14, 18) - (14, 19) "a"
                              . (14, 19) - (14, 20) "."
                              field_identifier (14, 20) - (14, 21) "b"
                            ) (14, 21) - (14, 22) ")"
                        + (14, 23) - (14, 24) "+"
                        field_expression (14, 25) - (14, 28)
                          identifier (14, 25) - (14, 26) "a"
                          . (14, 26) - (14, 27) "."
                          field_identifier (14, 27) - (14, 28) "b"
                      + (14, 29) - (14, 30) "+"
                      field_expression (14, 31) - (14, 36)
                        field_expression (14, 31) - (14, 34)
                          identifier (14, 31) - (14, 32) "a"
                          . (14, 32) - (14, 33) "."
                          field_identifier (14, 33) - (14, 34) "b"
                        . (14, 34) - (14, 35) "."
                        field_identifier (14, 35) - (14, 36) "c"
                    + (14, 37) - (14, 38) "+"
                    field_expression (14, 39) - (14, 44)
                      field_expression (14, 39) - (14, 42)
                        identifier (14, 39) - (14, 40) "a"
                        . (14, 40) - (14, 41) "."
                        field_identifier (14, 41) - (14, 42) "b"
                      . (14, 42) - (14, 43) "."
                      field_identifier (14, 43) - (14, 44) "c"
                  + (14, 45) - (14, 46) "+"
                  field_expression (14, 47) - (14, 50)
                    identifier (14, 47) - (14, 48) "a"
                    . (14, 48) - (14, 49) "."
                    field_identifier (14, 49) - (14, 50) "b"
              ; (14, 50) - (14, 51) ";"
            } (15, 2) - (15, 3) "}"
      } (16, 0) - (16, 1) "}"
[
    List id:1 content:21 {
        open_content: "",
        open_position: "0:0-0",
        children: [
            Atom id:2 content:1 {
                content: "static",
                position: "0:0-6",
            },
            Atom id:3 content:2 {
                content: "void",
                position: "0:7-11",
            },
            List id:4 content:5 {
                open_content: "",
                open_position: "0:12-12",
                children: [
                    Atom id:5 content:3 {
                        content: "foo",
                        position: "0:12-15",
                    },
                    List id:6 content:4 {
                        open_content: "(",
                        open_position: "0:15-16",
                        children: [
                            Atom id:7 content:2 {
                                content: "void",
                                position: "0:16-20",
                            },
                        ],
                        close_content: ")",
                        close_position: "0:20-21",
                    },
                ],
                close_content: "",
                close_position: "0:21-21",
            },
            List id:8 content:20 {
                open_content: "{",
                open_position: "0:22-23",
                children: [
                    List id:9 content:19 {
                        open_content: "",
                        open_position: "1:0-0",
                        children: [
                            Atom id:10 content:6 {
                                content: "#if",
                                position: "1:0-3",
                            },
                            Atom id:11 content:7 {
                                content: "FOREVER",
                                position: "1:4-11",
                            },
                            List id:12 content:18 {
                                open_content: "",
                                open_position: "2:2-2",
                                children: [
                                    Atom id:13 content:8 {
                                        content: "while",
                                        position: "2:2-7",
                                    },
                                    List id:14 content:10 {
                                        open_content: "(",
                                        open_position: "2:8-9",
                                        children: [
                                            Atom id:15 content:9 {
                                                content: "1",
                                                position: "2:9-10",
                                            },
                                        ],
                                        close_content: ")",
                                        close_position: "2:10-11",
                                    },
                                    List id:16 content:17 {
                                        open_content: "{",
                                        open_position: "2:12-13",
                                        children: [
                                            Atom id:17 content:11 {
                                                content: "#endif",
                                                position: "3:0-6",
                                            },
                                            List id:18 content:15 {
                                                open_content: "",
                                                open_position: "4:2-2",
                                                children: [
                                                    List id:19 content:13 {
                                                        open_content: "",
                                                        open_position: "4:2-2",
                                                        children: [
                                                            Atom id:20 content:3 {
                                                                content: "foo",
                                                                position: "4:2-5",
                                                            },
                                                            List id:21 content:12 {
                                                                open_content: "(",
                                                                open_position: "4:5-6",
                                                                children: [],
                                                                close_content: ")",
                                                                close_position: "4:6-7",
                                                            },
                                                        ],
                                                        close_content: "",
                                                        close_position: "4:7-7",
                                                    },
                                                    Atom id:22 content:14 {
                                                        content: ";",
                                                        position: "4:7-8",
                                                    },
                                                ],
                                                close_content: "",
                                                close_position: "4:8-8",
                                            },
                                            List id:23 content:16 {
                                                open_content: "",
                                                open_position: "5:0-0",
                                                children: [
                                                    Atom id:24 content:6 {
                                                        content: "#if",
                                                        position: "5:0-3",
                                                    },
                                                    Atom id:25 content:7 {
                                                        content: "FOREVER",
                                                        position: "5:4-11",
                                                    },
                                                ],
                                                close_content: "",
                                                close_position: "6:0-0",
                                            },
                                        ],
                                        close_content: "}",
                                        close_position: "6:2-3",
                                    },
                                ],
                                close_content: "",
                                close_position: "6:3-3",
                            },
                            Atom id:26 content:11 {
                                content: "#endif",
                                position: "7:0-6",
                            },
                        ],
                        close_content: "",
                        close_position: "7:6-6",
                    },
                ],
                close_content: "}",
                close_position: "8:0-1",
            },
        ],
        close_content: "",
        close_position: "8:1-1",
    },
    List id:27 content:54 {
        open_content: "",
        open_position: "10:0-0",
        children: [
            Atom id:28 content:1 {
                content: "static",
                position: "10:0-6",
            },
            Atom id:29 content:2 {
                content: "void",
                position: "10:7-11",
            },
            List id:30 content:23 {
                open_content: "",
                open_position: "10:12-12",
                children: [
                    Atom id:31 content:22 {
                        content: "bar",
                        position: "10:12-15",
                    },
                    List id:32 content:4 {
                        open_content: "(",
                        open_position: "10:15-16",
                        children: [
                            Atom id:33 content:2 {
                                content: "void",
                                position: "10:16-20",
                            },
                        ],
                        close_content: ")",
                        close_position: "10:20-21",
                    },
                ],
                close_content: "",
                close_position: "10:21-21",
            },
            List id:34 content:53 {
                open_content: "{",
                open_position: "10:22-23",
                children: [
                    List id:35 content:52 {
                        open_content: "",
                        open_position: "11:2-2",
                        children: [
                            Atom id:36 content:24 {
                                content: "if",
                                position: "11:2-4",
                            },
                            List id:37 content:10 {
                                open_content: "(",
                                open_position: "11:5-6",
                                children: [
                                    Atom id:38 content:9 {
                                        content: "1",
                                        position: "11:6-7",
                                    },
                                ],
                                close_content: ")",
                                close_position: "11:7-8",
                            },
                            List id:39 content:42 {
                                open_content: "{",
                                open_position: "11:9-10",
                                children: [
                                    List id:40 content:41 {
                                        open_content: "",
                                        open_position: "12:4-4",
                                        children: [
                                            List id:41 content:40 {
                                                open_content: "",
                                                open_position: "12:4-4",
                                                children: [
                                                    Atom id:42 content:25 {
                                                        content: "var",
                                                        position: "12:4-7",
                                                    },
                                                    Atom id:43 content:26 {
                                                        content: "=",
                                                        position: "12:8-9",
                                                    },
                                                    List id:44 content:39 {
                                                        open_content: "(",
                                                        open_position: "12:10-11",
                                                        children: [
                                                            List id:45 content:38 {
                                                                open_content: "",
                                                                open_position: "12:11-11",
                                                                children: [
                                                                    List id:46 content:34 {
                                                                        open_content: "",
                                                                        open_position: "12:11-11",
                                                                        children: [
                                                                            Atom id:47 content:27 {
                                                                                content: "func",
                                                                                position: "12:11-15",
                                                                            },
                                                                            List id:48 content:33 {
                                                                                open_content: "(",
                                                                                open_position: "12:15-16",
                                                                                children: [
                                                                                    Atom id:49 content:28 {
                                                                                        content: "a",
                                                                                        position: "12:16-17",
                                                                                    },
                                                                                    Atom id:50 content:29 {
                                                                                        content: ",",
                                                                                        position: "12:17-18",
                                                                                    },
                                                                                    List id:51 content:32 {
                                                                                        open_content: "",
                                                                                        open_position: "12:19-19",
                                                                                        children: [
                                                                                            Atom id:52 content:28 {
                                                                                                content: "a",
                                                                                                position: "12:19-20",
                                                                                            },
                                                                                            Atom id:53 content:30 {
                                                                                                content: ".",
                                                                                                position: "12:20-21",
                                                                                            },
                                                                                            Atom id:54 content:31 {
                                                                                                content: "b",
                                                                                                position: "12:21-22",
                                                                                            },
                                                                                        ],
                                                                                        close_content: "",
                                                                                        close_position: "12:22-22",
                                                                                    },
                                                                                ],
                                                                                close_content: ")",
                                                                                close_position: "12:22-23",
                                                                            },
                                                                        ],
                                                                        close_content: "",
                                                                        close_position: "12:23-23",
                                                                    },
                                                                    Atom id:55 content:35 {
                                                                        content: "+",
                                                                        position: "12:24-25",
                                                                    },
                                                                    List id:56 content:37 {
                                                                        open_content: "",
                                                                        open_position: "12:26-26",
                                                                        children: [
                                                                            List id:57 content:32 {
                                                                                open_content: "",
                                                                                open_position: "12:26-26",
                                                                                children: [
                                                                                    Atom id:58 content:28 {
                                                                                        content: "a",
                                                                                        position: "12:26-27",
                                                                                    },
                                                                                    Atom id:59 content:30 {
                                                                                        content: ".",
                                                                                        position: "12:27-28",
                                                                                    },
                                                                                    Atom id:60 content:31 {
                                                                                        content: "b",
                                                                                        position: "12:28-29",
                                                                                    },
                                                                                ],
                                                                                close_content: "",
                                                                                close_position: "12:29-29",
                                                                            },
                                                                            Atom id:61 content:30 {
                                                                                content: ".",
                                                                                position: "12:29-30",
                                                                            },
                                                                            Atom id:62 content:36 {
                                                                                content: "c",
                                                                                position: "12:30-31",
                                                                            },
                                                                        ],
                                                                        close_content: "",
                                                                        close_position: "12:31-31",
                                                                    },
                                                                ],
                                                                close_content: "",
                                                                close_position: "12:31-31",
                                                            },
                                                        ],
                                                        close_content: ")",
                                                        close_position: "12:31-32",
                                                    },
                                                ],
                                                close_content: "",
                                                close_position: "12:32-32",
                                            },
                                            Atom id:63 content:14 {
                                                content: ";",
                                                position: "12:32-33",
                                            },
                                        ],
                                        close_content: "",
                                        close_position: "12:33-33",
                                    },
                                ],
                                close_content: "}",
                                close_position: "13:2-3",
                            },
                            List id:64 content:51 {
                                open_content: "",
                                open_position: "13:4-4",
                                children: [
                                    Atom id:65 content:43 {
                                        content: "else",
                                        position: "13:4-8",
                                    },
                                    List id:66 content:50 {
                                        open_content: "{",
                                        open_position: "13:9-10",
                                        children: [
                                            List id:67 content:49 {
                                                open_content: "",
                                                open_position: "14:4-4",
                                                children: [
                                                    List id:68 content:48 {
                                                        open_content: "",
                                                        open_position: "14:4-4",
                                                        children: [
                                                            Atom id:69 content:25 {
                                                                content: "var",
                                                                position: "14:4-7",
                                                            },
                                                            Atom id:70 content:26 {
                                                                content: "=",
                                                                position: "14:8-9",
                                                            },
                                                            List id:71 content:47 {
                                                                open_content: "",
                                                                open_position: "14:10-10",
                                                                children: [
                                                                    List id:72 content:46 {
                                                                        open_content: "",
                                                                        open_position: "14:10-10",
                                                                        children: [
                                                                            List id:73 content:45 {
                                                                                open_content: "",
                                                                                open_position: "14:10-10",
                                                                                children: [
                                                                                    List id:74 content:44 {
                                                                                        open_content: "",
                                                                                        open_position: "14:10-10",
                                                                                        children: [
                                                                                            List id:75 content:34 {
                                                                                                open_content: "",
                                                                                                open_position: "14:10-10",
                                                                                                children: [
                                                                                                    Atom id:76 content:27 {
                                                                                                        content: "func",
                                                                                                        position: "14:10-14",
                                                                                                    },
                                                                                                    List id:77 content:33 {
                                                                                                        open_content: "(",
                                                                                                        open_position: "14:14-15",
                                                                                                        children: [
                                                                                                            Atom id:78 content:28 {
                                                                                                                content: "a",
                                                                                                                position: "14:15-16",
                                                                                                            },
                                                                                                            Atom id:79 content:29 {
                                                                                                                content: ",",
                                                                                                                position: "14:16-17",
                                                                                                            },
                                                                                                            List id:80 content:32 {
                                                                                                                open_content: "",
                                                                                                                open_position: "14:18-18",
                                                                                                                children: [
                                                                                                                    Atom id:81 content:28 {
                                                                                                                        content: "a",
                                                                                                                        position: "14:18-19",
                                                                                                                    },
                                                                                                                    Atom id:82 content:30 {
                                                                                                                        content: ".",
                                                                                                                        position: "14:19-20",
                                                                                                                    },
                                                                                                                    Atom id:83 content:31 {
                                                                                                                        content: "b",
                                                                                                                        position: "14:20-21",
                                                                                                                    },
                                                                                                                ],
                                                                                                                close_content: "",
                                                                                                                close_position: "14:21-21",
                                                                                                            },
                                                                                                        ],
                                                                                                        close_content: ")",
                                                                                                        close_position: "14:21-22",
                                                                                                    },
                                                                                                ],
                                                                                                close_content: "",
                                                                                                close_position: "14:22-22",
                                                                                            },
                                                                                            Atom id:84 content:35 {
                                                                                                content: "+",
                                                                                                position: "14:23-24",
                                                                                            },
                                                                                            List id:85 content:32 {
                                                                                                open_content: "",
                                                                                                open_position: "14:25-25",
                                                                                                children: [
                                                                                                    Atom id:86 content:28 {
                                                                                                        content: "a",
                                                                                                        position: "14:25-26",
                                                                                                    },
                                                                                                    Atom id:87 content:30 {
                                                                                                        content: ".",
                                                                                                        position: "14:26-27",
                                                                                                    },
                                                                                                    Atom id:88 content:31 {
                                                                                                        content: "b",
                                                                                                        position: "14:27-28",
                                                                                                    },
                                                                                                ],
                                                                                                close_content: "",
                                                                                                close_position: "14:28-28",
                                                                                            },
                                                                                        ],
                                                                                        close_content: "",
                                                                                        close_position: "14:28-28",
                                                                                    },
                                                                                    Atom id:89 content:35 {
                                                                                        content: "+",
                                                                                        position: "14:29-30",
                                                                                    },
                                                                                    List id:90 content:37 {
                                                                                        open_content: "",
                                                                                        open_position: "14:31-31",
                                                                                        children: [
                                                                                            List id:91 content:32 {
                                                                                                open_content: "",
                                                                                                open_position: "14:31-31",
                                                                                                children: [
                                                                                                    Atom id:92 content:28 {
                                                                                                        content: "a",
                                                                                                        position: "14:31-32",
                                                                                                    },
                                                                                                    Atom id:93 content:30 {
                                                                                                        content: ".",
                                                                                                        position: "14:32-33",
                                                                                                    },
                                                                                                    Atom id:94 content:31 {
                                                                                                        content: "b",
                                                                                                        position: "14:33-34",
                                                                                                    },
                                                                                                ],
                                                                                                close_content: "",
                                                                                                close_position: "14:34-34",
                                                                                            },
                                                                                            Atom id:95 content:30 {
                                                                                                content: ".",
                                                                                                position: "14:34-35",
                                                                                            },
                                                                                            Atom id:96 content:36 {
                                                                                                content: "c",
                                                                                                position: "14:35-36",
                                                                                            },
                                                                                        ],
                                                                                        close_content: "",
                                                                                        close_position: "14:36-36",
                                                                                    },
                                                                                ],
                                                                                close_content: "",
                                                                                close_position: "14:36-36",
                                                                            },
                                                                            Atom id:97 content:35 {
                                                                                content: "+",
                                                                                position: "14:37-38",
                                                                            },
                                                                            List id:98 content:37 {
                                                                                open_content: "",
                                                                                open_position: "14:39-39",
                                                                                children: [
                                                                                    List id:99 content:32 {
                                                                                        open_content: "",
                                                                                        open_position: "14:39-39",
                                                                                        children: [
                                                                                            Atom id:100 content:28 {
                                                                                                content: "a",
                                                                                                position: "14:39-40",
                                                                                            },
                                                                                            Atom id:101 content:30 {
                                                                                                content: ".",
                                                                                                position: "14:40-41",
                                                                                            },
                                                                                            Atom id:102 content:31 {
                                                                                                content: "b",
                                                                                                position: "14:41-42",
                                                                                            },
                                                                                        ],
                                                                                        close_content: "",
                                                                                        close_position: "14:42-42",
                                                                                    },
                                                                                    Atom id:103 content:30 {
                                                                                        content: ".",
                                                                                        position: "14:42-43",
                                                                                    },
                                                                                    Atom id:104 content:36 {
                                                                                        content: "c",
                                                                                        position: "14:43-44",
                                                                                    },
                                                                                ],
                                                                                close_content: "",
                                                                                close_position: "14:44-44",
                                                                            },
                                                                        ],
                                                                        close_content: "",
                                                                        close_position: "14:44-44",
                                                                    },
                                                                    Atom id:105 content:35 {
                                                                        content: "+",
                                                                        position: "14:45-46",
                                                                    },
                                                                    List id:106 content:32 {
                                                                        open_content: "",
                                                                        open_position: "14:47-47",
                                                                        children: [
                                                                            Atom id:107 content:28 {
                                                                                content: "a",
                                                                                position: "14:47-48",
                                                                            },
                                                                            Atom id:108 content:30 {
                                                                                content: ".",
                                                                                position: "14:48-49",
                                                                            },
                                                                            Atom id:109 content:31 {
                                                                                content: "b",
                                                                                position: "14:49-50",
                                                                            },
                                                                        ],
                                                                        close_content: "",
                                                                        close_position: "14:50-50",
                                                                    },
                                                                ],
                                                                close_content: "",
                                                                close_position: "14:50-50",
                                                            },
                                                        ],
                                                        close_content: "",
                                                        close_position: "14:50-50",
                                                    },
                                                    Atom id:110 content:14 {
                                                        content: ";",
                                                        position: "14:50-51",
                                                    },
                                                ],
                                                close_content: "",
                                                close_position: "14:51-51",
                                            },
                                        ],
                                        close_content: "}",
                                        close_position: "15:2-3",
                                    },
                                ],
                                close_content: "",
                                close_position: "15:3-3",
                            },
                        ],
                        close_content: "",
                        close_position: "15:3-3",
                    },
                ],
                close_content: "}",
                close_position: "16:0-1",
            },
        ],
        close_content: "",
        close_position: "16:1-1",
    },
]

There seems to be some form of limit at play here that produces an error node over a certain code complexity.

The output of tree-sitter parse in tree-sitter-c v0.20.4 looks good in both cases, so it seems to be a difft thing.

$ difft --version
Difftastic 0.57.0 (5b942908f 2024-04-22, built with rustc 1.77.1)