[Yul] Output an error of a switch case which contains string literals longer than 32 chars

This commit is contained in:
hydai
2019-04-17 22:17:18 +08:00
parent 4509e8efbb
commit d5b65fbf5b
2 changed files with 13 additions and 1 deletions
+7 -1
View File
@@ -442,15 +442,21 @@ bool AsmAnalyzer::operator()(Switch const& _switch)
if (_case.value)
{
int const initialStackHeight = m_stackHeight;
bool isCaseValueValid = true;
// We cannot use "expectExpression" here because *_case.value is not a
// Statement and would be converted to a Statement otherwise.
if (!(*this)(*_case.value))
{
isCaseValueValid = false;
success = false;
}
expectDeposit(1, initialStackHeight, _case.value->location);
m_stackHeight--;
// If the case value is not valid, we should not insert it into cases.
yulAssert(isCaseValueValid || m_errorReporter.hasErrors(), "Invalid case value.");
/// Note: the parser ensures there is only one default case
if (!cases.insert(valueOfLiteral(*_case.value)).second)
if (isCaseValueValid && !cases.insert(valueOfLiteral(*_case.value)).second)
{
m_errorReporter.declarationError(
_case.location,