fix: Restrict commutativity of initializer_list in C/C++ #377
10 changed files with 59 additions and 1 deletions
5
examples/cpp/working/json_in_cpp/Base.cpp
Normal file
5
examples/cpp/working/json_in_cpp/Base.cpp
Normal file
|
@ -0,0 +1,5 @@
|
|||
json func() {
|
||||
return json{{"num", 0},
|
||||
{"obj", {{"a", 1}, {"b", 2}}},
|
||||
{"list", json::array({{{"a", 3}, {"b", 4}}})}};
|
||||
}
|
17
examples/cpp/working/json_in_cpp/Expected.cpp
Normal file
17
examples/cpp/working/json_in_cpp/Expected.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
json func() {
|
||||
return json{{"num", 0},
|
||||
<<<<<<< LEFT
|
||||
{"list", json::array({{{"a", 1}, {"b", 2}}})},
|
||||
||||||| BASE
|
||||
{{"num", 0},
|
||||
{"obj", {{"a", 1}, {"b", 2}}},
|
||||
{"list", json::array({{{"a", 3}, {"b", 4}}})}},
|
||||
=======
|
||||
{{"num", 0},
|
||||
{"obj", {{"a", 1}, {"b", 2}}},
|
||||
{"list", json::array({{{"a", 3}, {"b", 4}}})},
|
||||
{"c", 5}},
|
||||
>>>>>>> RIGHT
|
||||
{"other", {{"a", 3}, {"b", 4}}},
|
||||
{"c", 5}};
|
||||
}
|
6
examples/cpp/working/json_in_cpp/Left.cpp
Normal file
6
examples/cpp/working/json_in_cpp/Left.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
json func() {
|
||||
return json{{"num", 0},
|
||||
{"list", json::array({{{"a", 1}, {"b", 2}}})},
|
||||
{"other", {{"a", 3}, {"b", 4}}},
|
||||
{"c", 5}};
|
||||
}
|
1
examples/cpp/working/json_in_cpp/README
Normal file
1
examples/cpp/working/json_in_cpp/README
Normal file
|
@ -0,0 +1 @@
|
|||
Taken from https://codeberg.org/mergiraf/mergiraf/issues/262
|
6
examples/cpp/working/json_in_cpp/Right.cpp
Normal file
6
examples/cpp/working/json_in_cpp/Right.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
json func() {
|
||||
return json{{"num", 0},
|
||||
{"obj", {{"a", 1}, {"b", 2}}},
|
||||
{"list", json::array({{{"a", 3}, {"b", 4}}})},
|
||||
{"c", 5}};
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
my_struct_t instance = {
|
||||
"hello"
|
||||
};
|
|
@ -0,0 +1,11 @@
|
|||
my_struct_t instance = {
|
||||
<<<<<<< LEFT
|
||||
"hello",
|
||||
"merhaba",
|
||||
||||||| BASE
|
||||
"hello"
|
||||
=======
|
||||
"hello",
|
||||
"salut",
|
||||
>>>>>>> RIGHT
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
my_struct_t instance = {
|
||||
"hello",
|
||||
"merhaba",
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
my_struct_t instance = {
|
||||
"hello",
|
||||
"salut",
|
||||
};
|
|
@ -444,7 +444,8 @@ pub static SUPPORTED_LANGUAGES: LazyLock<Vec<LangProfile>> = LazyLock::new(|| {
|
|||
language: tree_sitter_cpp::LANGUAGE.into(),
|
||||
atomic_nodes: vec![],
|
||||
commutative_parents: vec![
|
||||
CommutativeParent::new("initializer_list", "{", ",", "}"),
|
||||
CommutativeParent::new("initializer_list", "{", ",", "}")
|
||||
.restricted_to_groups(&[&["initializer_pair"]]),
|
||||
CommutativeParent::new("field_declaration_list", "{\n", "\n", "\n}\n")
|
||||
.restricted_to_groups(&[&["field_declaration"], &["function_definition"]]),
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue