}
Substring FoldOperation(FoldingContext &context, Substring &&substring) {
- std::optional<Expr<SubscriptInteger>> lower{Fold(context, substring.lower())};
- std::optional<Expr<SubscriptInteger>> upper{Fold(context, substring.upper())};
+ std::optional<Expr<SubscriptInteger>> lower, upper;
+ if (auto *p{substring.lower()}) {
+ lower = Fold(context, std::move(*p));
+ }
+ if (auto *p{substring.upper()}) {
+ upper = Fold(context, std::move(*p));
+ }
if (const DataRef * dataRef{substring.GetParentIf<DataRef>()}) {
return Substring{FoldOperation(context, DataRef{*dataRef}),
std::move(lower), std::move(upper)};