mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Variant: Do not use implicit fall-through
The code handling the comparison between the date and string types would convert the variants to correct types, but only through multi-level fall-through in the switch statement, which is always a bit of a dangerous construct. Added explicit return for the non-trivial case, preventing the need for the fall-through. Closes #2502.
This commit is contained in:
parent
8f16824538
commit
8b86f16f25
1 changed files with 9 additions and 2 deletions
|
@ -1098,8 +1098,15 @@ bool Variant::operator_partial (const Variant& other) const
|
||||||
{
|
{
|
||||||
// Same-day comparison.
|
// Same-day comparison.
|
||||||
case type_string:
|
case type_string:
|
||||||
if (left.trivial () || right.trivial ())
|
{
|
||||||
return false;
|
if (left.trivial () || right.trivial ())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
right.cast (type_date);
|
||||||
|
Datetime left_date (left._date);
|
||||||
|
Datetime right_date (right._date);
|
||||||
|
return left_date.sameDay (right_date);
|
||||||
|
}
|
||||||
|
|
||||||
case type_boolean:
|
case type_boolean:
|
||||||
case type_integer:
|
case type_integer:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue