Cleanup code around JERRY_UNREACHABLEs (#2342)
`JERRY_UNREACHABLE`s often signal code structure that could be improved: they can usually either be rewritten to `JERRY_ASSERT`s or eliminated by restructuring loops, `if`s or `#if`s. Roughly, the only valid occurences are in default cases of `switch`es. And even they can often be merged into non-default cases. Moreover, it is dangerous to write meaningful code after `JERRY_UNREACHABLE` because it pretends as if there was a way to recover from an impossible situation. This patch rewrites/eliminates `JERRY_UNREACHABLE`s where possible and removes misleading code from after them. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
@@ -82,12 +82,6 @@ ecma_new_standard_error (ecma_standard_error_t error_type) /**< native error typ
|
||||
|
||||
switch (error_type)
|
||||
{
|
||||
case ECMA_ERROR_COMMON:
|
||||
{
|
||||
prototype_id = ECMA_BUILTIN_ID_ERROR_PROTOTYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_ERROR_EVAL:
|
||||
{
|
||||
prototype_id = ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE;
|
||||
@@ -124,9 +118,11 @@ ecma_new_standard_error (ecma_standard_error_t error_type) /**< native error typ
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_ERROR_NONE:
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
JERRY_ASSERT (error_type == ECMA_ERROR_COMMON);
|
||||
|
||||
prototype_id = ECMA_BUILTIN_ID_ERROR_PROTOTYPE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user