Skip to content

Commit 26c1ffa

Browse files
authored
Fix build with disabled ES2015 module system (#4084)
With a disabled ES2015 module system the build fails as an enum value is incorrectly guarded and used. JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
1 parent b4a4619 commit 26c1ffa

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

jerry-core/parser/js/js-parser-statm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,11 @@ parser_parse_function_statement (parser_context_t *context_p) /**< context */
680680
{
681681
parser_raise_error (context_p, PARSER_ERR_VARIABLE_REDECLARED);
682682
}
683+
684+
uint16_t function_name_index = context_p->lit_object.index;
683685
#endif /* ENABLED (JERRY_ESNEXT) */
684686

685687
#if ENABLED (JERRY_MODULE_SYSTEM)
686-
uint16_t function_name_index = context_p->lit_object.index;
687688
parser_module_append_export_name (context_p);
688689
context_p->status_flags &= (uint32_t) ~(PARSER_MODULE_STORE_IDENT);
689690
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */

jerry-core/parser/js/js-scanner-util.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,13 +1739,19 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
17391739
}
17401740
else if (check_type == PARSER_CHECK_GLOBAL_CONTEXT)
17411741
{
1742+
#if ENABLED (JERRY_MODULE_SYSTEM)
1743+
const bool is_import = (type == SCANNER_STREAM_TYPE_IMPORT);
1744+
#else
1745+
const bool is_import = true;
1746+
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
1747+
17421748
/* FIXME: a private declarative lexical environment should always be present
17431749
* for modules. Remove SCANNER_STREAM_TYPE_IMPORT after it is implemented. */
17441750
JERRY_ASSERT (type == SCANNER_STREAM_TYPE_VAR
17451751
|| type == SCANNER_STREAM_TYPE_LET
17461752
|| type == SCANNER_STREAM_TYPE_CONST
17471753
|| type == SCANNER_STREAM_TYPE_FUNC
1748-
|| type == SCANNER_STREAM_TYPE_IMPORT);
1754+
|| is_import);
17491755

17501756
/* Only let/const can be stored in registers */
17511757
JERRY_ASSERT ((data & SCANNER_STREAM_NO_REG)
@@ -1792,10 +1798,16 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
17921798
}
17931799

17941800
#if ENABLED (JERRY_ESNEXT)
1801+
#if ENABLED (JERRY_MODULE_SYSTEM)
1802+
const bool is_import = (type == SCANNER_STREAM_TYPE_IMPORT);
1803+
#else
1804+
const bool is_import = true;
1805+
#endif /* ENABLED (JERRY_MODULE_SYSTEM) */
1806+
17951807
if (JERRY_UNLIKELY (check_type == PARSER_CHECK_GLOBAL_CONTEXT)
17961808
&& (type == SCANNER_STREAM_TYPE_VAR
17971809
|| (type == SCANNER_STREAM_TYPE_FUNC && !(context_p->global_status_flags & ECMA_PARSE_DIRECT_EVAL))
1798-
|| type == SCANNER_STREAM_TYPE_IMPORT))
1810+
|| is_import))
17991811
{
18001812
continue;
18011813
}

tools/run-tests.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ def skip_if(condition, desc):
159159
['--cmake-param=-DENABLE_ALL_IN_ONE_SOURCE=ON']),
160160
Options('buildoption_test-jerry-debugger',
161161
['--jerry-debugger=on']),
162+
Options('buildoption_test-module-off',
163+
['--compile-flag=-DJERRY_MODULE_SYSTEM=0', '--lto=off']),
162164
]
163165

164166
def get_arguments():

0 commit comments

Comments
 (0)