ThirdWednesdayInclusive reported as 'unknown rule' in Schedule firstDate/nextToLastDate validation and catbond stubDate switch
Summary
DateGeneration::ThirdWednesdayInclusive (added in 2021) is missing from two switch statements, so a valid rule is reported as "unknown rule (4)":
- The
Scheduleconstructor validation switches forfirstDateandnextToLastDate(ql/time/schedule.cpp, theQL_FAIL("unknown rule (...")arms): a schedule with afirstDateand this rule dies even though the rule is valid.
import QuantLib as ql
ql.Schedule(ql.Date(15,1,2025), ql.Date(15,4,2026), ql.Period('3M'), ql.TARGET(),
ql.Following, ql.Following, ql.DateGeneration.ThirdWednesdayInclusive,
False, ql.Date(15,4,2025), ql.Date())
# RuntimeError: unknown rule (4)
Rules that were handled produce the correct behavior (either generate or reject with a rule-specific message).
- The
stubDateswitch inql/experimental/catbonds/catbond.cpp(default: QL_FAIL("unknown ... rule")): it handles Backward/Forward and rejects Zero/ThirdWednesday/Twentieth with their own messages, but CDS, CDS2015, OldCDS, and ThirdWednesdayInclusive fall to thedefaultarm and are reported as unknown rules.
Mechanism
The 2021 commit that introduced ThirdWednesdayInclusive added the enumerator to the generation switch but not to the validation switches. catbond.cpp predates the new enumerators entirely.
Impact
Functional gap for a public enum value, four years live: valid input rejected with a misleading message. Same species as the historical enum-totality issues (e.g. PR #1974).
Suggested fix
Add ThirdWednesdayInclusive to the firstDate/nextToLastDate validation switches in schedule.cpp (with whatever the intended handling is: either the rule-specific generation path or an explicit incompatibility message), and add CDS/CDS2015/OldCDS/ThirdWednesdayInclusive handling to the catbond.cpp stubDate switch.
Environment
QuantLib-Python 1.44; verified in source at master e429e9f1 (ql/time/schedule.cpp, ql/experimental/catbonds/catbond.cpp).
Found by a formal-verification audit of historical QuantLib PRs; AI-assisted (ZCode/GLM-5.3-flash).
Hi, I'd like to take this one. I have a fix ready and will open a PR shortly.