fix: do not use assert-only never reached branch

This commit is contained in:
ToruNiina
2024-06-16 19:32:54 +09:00
parent 872ef72572
commit 6f05bffb5f
2 changed files with 14 additions and 5 deletions

View File

@@ -157,9 +157,15 @@ parse_boolean(location& loc, const context<TC>& ctx)
// it matches. gen value // it matches. gen value
const auto str = reg.as_string(); const auto str = reg.as_string();
const auto val = [&str]() { const auto val = [&str]() {
if (str == "true") { return true; } if(str == "true")
else if(str == "false") { return false; } {
else {assert("never reach here" && false);} return true;
}
else
{
assert(str == "false");
return false;
}
}(); }();
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------

View File

@@ -147,9 +147,12 @@ read_int(const std::string& str, const source_location src, const std::uint8_t b
{ {
case 2: { return read_bin_int<T>(str, src); } case 2: { return read_bin_int<T>(str, src); }
case 8: { return read_oct_int<T>(str, src); } case 8: { return read_oct_int<T>(str, src); }
case 10: { return read_dec_int<T>(str, src); }
case 16: { return read_hex_int<T>(str, src); } case 16: { return read_hex_int<T>(str, src); }
default: { assert(false); } default:
{
assert(base == 10);
return read_dec_int<T>(str, src);
}
} }
} }