Skip to content

Commit

Permalink
Merge pull request #461 from biojppm/fix/455
Browse files Browse the repository at this point in the history
fix parsing of val-less nested maps when deindented to maps
  • Loading branch information
biojppm authored Aug 13, 2024
2 parents 35fd478 + 10b7bbc commit 5e35659
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog/current.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Fixes

- Fix [#455](https://github.com/biojppm/rapidyaml/issues/455): parsing of trailing val-less nested maps when deindented to maps ([PR#460](https://github.com/biojppm/rapidyaml/pull/460))
- Fix filtering of double-quoted keys in block maps ([PR#452](https://github.com/biojppm/rapidyaml/pull/452))
- Fix [#440](https://github.com/biojppm/rapidyaml/issues/440): some tests failing with gcc -O2 (hypothetically due to undefined behavior)
- This was accomplished by refactoring some internal parser functions; see the comments in [#440](https://github.com/biojppm/rapidyaml/issues/440) for further details.
Expand Down
6 changes: 6 additions & 0 deletions src/c4/yml/parse_engine.def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6338,6 +6338,12 @@ void ParseEngine<EventHandler>::_handle_map_block()
{
_c4dbgp("mapblck[RVAL]: still mapblck!");
_line_progressed(m_evt_handler->m_curr->line_contents.indentation);
if(has_any(RNXT))
{
_c4dbgp("mapblck[RVAL]: speculatively expect next keyval");
m_evt_handler->add_sibling();
addrem_flags(RKEY, RNXT);
}
goto mapblck_again;
}
else
Expand Down
61 changes: 61 additions & 0 deletions test/test_github_issues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,67 @@
namespace c4 {
namespace yml {

TEST(github, 455_0_ok)
{
Tree t;
ExpectError::check_success([&t]{
parse_in_arena(R"(
processors:
- simple: a
sampler:
trace_id_ratio_based:
ratio:
)", &t);
});
ConstNodeRef sampler = t["sampler"];
ASSERT_TRUE(sampler.is_map());
ASSERT_TRUE(sampler.has_child("trace_id_ratio_based"));
ASSERT_TRUE(sampler["trace_id_ratio_based"].has_child("ratio"));
}

TEST(github, 455_0)
{
Tree t;
ExpectError::check_success([&t]{
parse_in_arena(R"(
processors:
- simple:
sampler:
trace_id_ratio_based:
ratio:
)", &t);
});
ConstNodeRef sampler = t["sampler"];
ASSERT_TRUE(sampler.is_map());
ASSERT_TRUE(sampler.has_child("trace_id_ratio_based"));
ASSERT_TRUE(sampler["trace_id_ratio_based"].has_child("ratio"));
}

TEST(github, 455_1)
{
Tree t;
ExpectError::check_success([&t]{
parse_in_arena(R"(
file_format: 0.0
tracer_provider:
processors:
- simple:
exporter:
console:
sampler:
trace_id_ratio_based:
ratio:
)", &t);
});
ConstNodeRef sampler = t["tracer_provider"]["sampler"];
ASSERT_TRUE(sampler.is_map());
ASSERT_TRUE(sampler.has_child("trace_id_ratio_based"));
ASSERT_TRUE(sampler["trace_id_ratio_based"].has_child("ratio"));
}


//-----------------------------------------------------------------------------

TEST(github, 268)
{
Tree tree = parse_in_arena(R"(
Expand Down

0 comments on commit 5e35659

Please sign in to comment.