Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`>>>({` after a qualified template call inside a template argument misparses the following braced-init as C compound literals

Aperta
#378 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
compilers

Direzione di ricerca

Start by reading the C++ grammar rules for qualified template calls, template arguments, and braced initializer lists, then add a regression case using the provided std::to_array reproducer. Check the resulting parse tree for one argument list containing nested initializer lists and no ERROR nodes; run the grammar’s parser tests to confirm the case passes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Did you check existing issues?
  • I have read all the tree-sitter docs if it relates to using the parser
  • I have searched the existing issues of tree-sitter-cpp
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

0.26.9

Describe the bug

The entire main becomes a top-level ERROR node. Inside it, each { ... } element of the initializer is parsed as compound_literal_expression with type: (MISSING type_identifier); successively they nest under comma_expression nodes, and the first element leaves a stray (ERROR) at the position of its closing }. The n<A>() call itself parses correctly as template_function with an abstract_function_declarator — the failure begins at the >>>({ that follows.

Steps To Reproduce/Bad Parse Tree
(translation_unit ; [0, 0] - [14, 0]
  (preproc_include ; [0, 0] - [1, 0]
    path: (system_lib_string)) ; [0, 9] - [0, 16]
  (preproc_include ; [1, 0] - [2, 0]
    path: (system_lib_string)) ; [1, 9] - [1, 22]
  (preproc_include ; [2, 0] - [3, 0]
    path: (system_lib_string)) ; [2, 9] - [2, 18]
  (namespace_definition ; [4, 0] - [4, 76]
    name: (namespace_identifier) ; [4, 10] - [4, 11]
    body: (declaration_list ; [4, 12] - [4, 76]
      (template_declaration ; [4, 14] - [4, 74]
        parameters: (template_parameter_list ; [4, 22] - [4, 34]
          (type_parameter_declaration ; [4, 23] - [4, 33]
            (type_identifier))) ; [4, 32] - [4, 33]
        (function_definition ; [4, 35] - [4, 74]
          (type_qualifier) ; [4, 35] - [4, 44]
          type: (qualified_identifier ; [4, 45] - [4, 56]
            scope: (namespace_identifier) ; [4, 45] - [4, 48]
            name: (type_identifier)) ; [4, 50] - [4, 56]
          declarator: (function_declarator ; [4, 57] - [4, 60]
            declarator: (identifier) ; [4, 57] - [4, 58]
            parameters: (parameter_list)) ; [4, 58] - [4, 60]
          body: (compound_statement ; [4, 61] - [4, 74]
            (return_statement ; [4, 63] - [4, 72]
              (number_literal))))))) ; [4, 70] - [4, 71]
  (enum_specifier ; [5, 0] - [5, 27]
    name: (type_identifier) ; [5, 11] - [5, 12]
    body: (enumerator_list ; [5, 13] - [5, 27]
      (enumerator ; [5, 15] - [5, 17]
        name: (identifier)) ; [5, 15] - [5, 17]
      (enumerator ; [5, 19] - [5, 21]
        name: (identifier)) ; [5, 19] - [5, 21]
      (enumerator ; [5, 23] - [5, 25]
        name: (identifier)))) ; [5, 23] - [5, 25]
  (ERROR ; [7, 0] - [13, 1]
    type: (primitive_type) ; [7, 0] - [7, 3]
    (function_declarator ; [7, 4] - [7, 10]
      declarator: (identifier) ; [7, 4] - [7, 8]
      parameters: (parameter_list)) ; [7, 8] - [7, 10]
    type: (placeholder_type_specifier ; [8, 4] - [8, 8]
      (auto)) ; [8, 4] - [8, 8]
    (identifier) ; [8, 9] - [8, 11]
    (binary_expression ; [8, 14] - [8, 83]
      left: (qualified_identifier ; [8, 14] - [8, 27]
        scope: (namespace_identifier) ; [8, 14] - [8, 17]
        name: (identifier)) ; [8, 19] - [8, 27]
      right: (qualified_identifier ; [8, 28] - [8, 83]
        scope: (namespace_identifier) ; [8, 28] - [8, 31]
        name: (template_function ; [8, 33] - [8, 83]
          name: (identifier) ; [8, 33] - [8, 37]
          arguments: (template_argument_list ; [8, 37] - [8, 83]
            (type_descriptor ; [8, 38] - [8, 41]
              type: (primitive_type)) ; [8, 38] - [8, 41]
            (type_descriptor ; [8, 43] - [8, 82]
              type: (qualified_identifier ; [8, 43] - [8, 82]
                scope: (namespace_identifier) ; [8, 43] - [8, 46]
                name: (template_type ; [8, 48] - [8, 82]
                  name: (type_identifier) ; [8, 48] - [8, 53]
                  arguments: (template_argument_list ; [8, 53] - [8, 82]
                    (type_descriptor ; [8, 54] - [8, 70]
                      type: (qualified_identifier ; [8, 54] - [8, 70]
                        scope: (namespace_identifier) ; [8, 54] - [8, 57]
                        name: (type_identifier))) ; [8, 59] - [8, 70]
                    (type_descriptor ; [8, 72] - [8, 81]
                      type: (qualified_identifier ; [8, 72] - [8, 79]
                        scope: (namespace_identifier) ; [8, 72] - [8, 73]
                        name: (template_type ; [8, 75] - [8, 79]
                          name: (type_identifier) ; [8, 75] - [8, 76]
                          arguments: (template_argument_list ; [8, 76] - [8, 79]
                            (type_descriptor ; [8, 77] - [8, 78]
                              type: (type_identifier))))) ; [8, 77] - [8, 78]
                      declarator: (abstract_function_declarator ; [8, 79] - [8, 81]
                        parameters: (parameter_list))))))))))) ; [8, 79] - [8, 81]
    (compound_statement ; [8, 85] - [13, 1]
      (compound_statement ; [9, 8] - [13, 1]
        (expression_statement ; [9, 10] - [12, 7]
          (comma_expression ; [9, 10] - [11, 22]
            left: (number_literal) ; [9, 10] - [9, 11]
            right: (comma_expression ; [9, 12] - [11, 22]
              left: (compound_literal_expression ; [9, 12] - [9, 20]
                type: (MISSING type_identifier) ; [9, 12] - [9, 12]
                value: (initializer_list ; [9, 13] - [9, 20]
                  (string_literal ; [9, 15] - [9, 18]
                    (string_content)))) ; [9, 16] - [9, 17]
              (ERROR) ; [9, 21] - [9, 22]
              right: (comma_expression ; [9, 23] - [11, 22]
                left: (compound_literal_expression ; [9, 23] - [10, 22]
                  type: (MISSING type_identifier) ; [9, 23] - [9, 23]
                  value: (initializer_list ; [10, 8] - [10, 22]
                    (number_literal) ; [10, 10] - [10, 11]
                    (initializer_list ; [10, 13] - [10, 20]
                      (string_literal ; [10, 15] - [10, 18]
                        (string_content))))) ; [10, 16] - [10, 17]
                right: (compound_literal_expression ; [10, 23] - [11, 22]
                  type: (MISSING type_identifier) ; [10, 23] - [10, 23]
                  value: (initializer_list ; [11, 8] - [11, 22]
                    (number_literal) ; [11, 10] - [11, 11]
                    (initializer_list ; [11, 13] - [11, 20]
                      (string_literal ; [11, 15] - [11, 18]
                        (string_content)))))))) ; [11, 16] - [11, 17]
          (ERROR)))))) ; [11, 22] - [12, 6]
Expected Behavior/Parse Tree

The argument to std::to_array<...> is an argument_list containing one initializer_list, whose elements are initializer_lists. No ERROR nodes.

Repro
#include <array>
#include <string_view>
#include <utility>

namespace m { template<typename T> constexpr std::size_t n() { return 3; } }
enum class A { A1, A2, A3 };

int main() {
    auto xs = std::to_array<std::pair<int, std::array<std::string_view, m::n<A>()>>>({
        { 1, { "a" } },
        { 2, { "b" } },
        { 3, { "c" } },
    });
}
Lingua principale
JavaScript
Stelle
463
Fork
190
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di tree-sitter/tree-sitter-cpp

Tutte le issue di tree-sitter/tree-sitter-cpp

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.