Commit bd9c5704 authored by Dominik Charousset's avatar Dominik Charousset

Merge pull request #1507

parents 15ab3fd7 24ca2859
......@@ -45,6 +45,7 @@ is based on [Keep a Changelog](https://keepachangelog.com).
- Fix a regression in `--dump-config` that caused CAF applications to emit
malformed output.
- Fix handling of WebSocket frames that are exactly on the 65535 byte limit.
- Fix crash when using a fallback value for optional values (#1427).
## [0.19.2] - 2023-06-13
......
......@@ -396,7 +396,10 @@ struct optional_inspector_access {
template <class Inspector, class IsPresent, class Get>
static bool save_field(Inspector& f, std::string_view field_name,
IsPresent& is_present, Get& get) {
return detail::save_field(f, field_name, is_present, get);
auto deref_get = [&get]() -> decltype(auto) {
return traits::deref_save(get());
};
return detail::save_field(f, field_name, is_present, deref_get);
}
template <class Inspector, class IsValid, class SyncValue>
......
......@@ -75,7 +75,7 @@ public:
template <class Inspector>
bool operator()(Inspector& f) {
auto is_present = [this] { return *val != fallback; };
auto get = [this] { return *val; };
auto get = [this]() -> decltype(auto) { return *val; };
return detail::save_field(f, field_name, is_present, get);
}
......
......@@ -769,4 +769,19 @@ end object)_";
}
}
TEST_CASE("GH-1427 regression") {
struct opt_test {
std::optional<int> val;
};
auto x = opt_test{};
CHECK(f.object(x).fields(f.field("val", x.val).fallback(std::nullopt)));
CHECK(!f.get_error());
std::string baseline = R"_(
begin object anonymous
begin optional field val
end field
end object)_";
CHECK_EQ(f.log, baseline);
}
END_FIXTURE_SCOPE()
......@@ -809,4 +809,19 @@ end object)_";
}
}
TEST_CASE("GH-1427 regression") {
struct opt_test {
std::optional<int> val;
};
auto x = opt_test{};
CHECK(f.object(x).fields(f.field("val", x.val).fallback(std::nullopt)));
CHECK(!f.get_error());
std::string baseline = R"_(
begin object anonymous
begin optional field val
end field
end object)_";
CHECK_EQ(f.log, baseline);
}
END_FIXTURE_SCOPE()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment