Fix precedence of interval operator
The interval operator has a lower precedence than, for example, binary operations. This was unexpected and incorrectly implemented in the output functions. For now, this is fixed by enclosing intervals in parentheses to avoid misinterpretations. The existing unit tests are adjusted to the updated output format.
This commit is contained in:
@@ -219,16 +219,16 @@ inline output::ColorStream &print(output::ColorStream &stream, const Integer &in
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline output::ColorStream &print(output::ColorStream &stream, const Interval &interval, PrintContext &printContext, bool)
|
||||
inline output::ColorStream &print(output::ColorStream &stream, const Interval &interval, PrintContext &printContext, bool omitParentheses)
|
||||
{
|
||||
if (printContext.context.parenthesisStyle == ParenthesisStyle::Full)
|
||||
if (!omitParentheses || printContext.context.parenthesisStyle == ParenthesisStyle::Full)
|
||||
stream << "(";
|
||||
|
||||
print(stream, interval.from, printContext);
|
||||
stream << "..";
|
||||
print(stream, interval.to, printContext);
|
||||
|
||||
if (printContext.context.parenthesisStyle == ParenthesisStyle::Full)
|
||||
if (!omitParentheses || printContext.context.parenthesisStyle == ParenthesisStyle::Full)
|
||||
stream << ")";
|
||||
|
||||
return stream;
|
||||
|
Reference in New Issue
Block a user