Nicer undefiend operator message

This commit is contained in:
Robert Bendun 2022-08-21 20:39:35 +02:00
parent 43555cbc1c
commit 5c53bb9e9f

View File

@ -317,6 +317,27 @@ std::ostream& operator<<(std::ostream& os, Error const& err)
os << '\n'; os << '\n';
print_error_line(loc); print_error_line(loc);
static constexpr auto Operators = std::array {
"and", "or",
"==", "!=", "<", ">", "<=", ">=",
"+", "+=", "-", "-=", "*", "*=", "/", "/=",
"&", "&=", "."
};
os << pretty::begin_comment;
os << "Operators that look familiar to one above:\n";
os << " ";
for (auto op : Operators) {
for (auto c : err.op) {
if (std::string_view(op).find(c) != std::string_view::npos) {
os << op << ' ';
break;
}
}
}
os << '\n' << pretty::end;
}, },
[&](errors::Unexpected_Keyword const&) { unimplemented(); }, [&](errors::Unexpected_Keyword const&) { unimplemented(); },
}, err.details); }, err.details);