Skip to content

Commit 7053815

Browse files
committed
Enable STRICT_JS by default
This has been enabled under `STRICT` mode since it was first added back in 2019 (#9265).
1 parent 97e3809 commit 7053815

File tree

6 files changed

+8
-15
lines changed

6 files changed

+8
-15
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
5.0.3 (in development)
2222
----------------------
23+
- The `STRICT_JS` setting is now on by default. Previously it was enabled by
24+
defualt only in `STRICT` mode. (#26421)
2325
- Warn on usage of the deprecated `EMSCRIPTEN` macro (`__EMSCRIPTEN__` should
2426
be used instead). (#26381)
2527
- The `-sRELOCATABLE` setting was effectively removed (moved to legacy

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1703,7 +1703,6 @@ Changes enabled by this:
17031703

17041704
- The C define EMSCRIPTEN is not defined (__EMSCRIPTEN__ always is, and
17051705
is the correct thing to use).
1706-
- STRICT_JS is enabled.
17071706
- IGNORE_MISSING_MAIN is disabled.
17081707
- AUTO_JS_LIBRARIES is disabled.
17091708
- AUTO_NATIVE_LIBRARIES is disabled.
@@ -1734,7 +1733,7 @@ STRICT_JS
17341733

17351734
Add ``"use strict;"`` to generated JS
17361735

1737-
Default value: false
1736+
Default value: true
17381737

17391738
.. _warn_on_undefined_symbols:
17401739

src/settings.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,6 @@ var LINKABLE = false;
11621162
//
11631163
// - The C define EMSCRIPTEN is not defined (__EMSCRIPTEN__ always is, and
11641164
// is the correct thing to use).
1165-
// - STRICT_JS is enabled.
11661165
// - IGNORE_MISSING_MAIN is disabled.
11671166
// - AUTO_JS_LIBRARIES is disabled.
11681167
// - AUTO_NATIVE_LIBRARIES is disabled.
@@ -1181,7 +1180,7 @@ var IGNORE_MISSING_MAIN = true;
11811180

11821181
// Add ``"use strict;"`` to generated JS
11831182
// [link]
1184-
var STRICT_JS = false;
1183+
var STRICT_JS = true;
11851184

11861185
// If set to 1, we will warn on any undefined symbols that are not resolved by
11871186
// the ``library_*.js`` files. Note that it is common in large projects to not

test/other/test_runtime_keepalive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ int main() {
88
Module["onExit"] = () => { out("onExit"); };
99
runtimeKeepalivePush();
1010
out("runtimeKeepalivePush done");
11-
counter = 0;
11+
var counter = 0;
1212
function timerCallback() {
1313
if (counter < 5) {
1414
runtimeKeepalivePush();

test/test_core.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ def decorated(self, textdecoder, *args, **kwargs):
411411

412412
no_safe_heap = make_no_decorator_for_setting('SAFE_HEAP')
413413
no_strict = make_no_decorator_for_setting('STRICT')
414-
no_strict_js = make_no_decorator_for_setting('STRICT_JS')
415414
no_big_endian = make_no_decorator_for_setting('SUPPORT_BIG_ENDIAN')
416415
no_omit_asm_module_exports = make_no_decorator_for_setting('DECLARE_ASM_MODULE_EXPORTS=0')
417416
no_js_math = make_no_decorator_for_setting('JS_MATH')
@@ -6306,7 +6305,6 @@ def test_jslib(self):
63066305
@with_env_modify({'LC_ALL': 'latin-1', 'PYTHONUTF8': '0', 'PYTHONCOERCECLOCALE': '0'})
63076306
@crossplatform
63086307
@no_modularize_instance('uses MODULARIZE')
6309-
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
63106308
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
63116309
def test_unicode_js_library(self):
63126310
# First verify that we have correct overridden the default python file encoding.
@@ -8038,7 +8036,6 @@ def get_wat_addr(call_index):
80388036

80398037
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
80408038
@no_modularize_instance('uses -sMODULARIZE')
8041-
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
80428039
def test_modularize_closure_pre(self):
80438040
# test that the combination of modularize + closure + pre-js works. in that mode,
80448041
# closure should not minify the Module object in a way that the pre-js cannot use it.
@@ -8985,7 +8982,6 @@ def test_asan_api(self):
89858982
self.do_core_test('test_asan_api.c', cflags=['-fsanitize=address'])
89868983

89878984
@asan
8988-
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
89898985
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
89908986
@no_modularize_instance('uses MODULARIZE')
89918987
def test_asan_modularized_with_closure(self):
@@ -9680,7 +9676,6 @@ def test_esm_integration(self):
96809676
self.assertFileContents(test_file('core/test_esm_integration.expected.mjs'), read_file('hello_world.mjs'))
96819677

96829678
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
9683-
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
96849679
def test_modularize_instance_hello(self):
96859680
self.do_core_test('test_hello_world.c', cflags=['-sMODULARIZE=instance', '-Wno-experimental'])
96869681

@@ -9689,7 +9684,6 @@ def test_modularize_instance_hello(self):
96899684
'pthreads': (['-pthread'],),
96909685
})
96919686
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
9692-
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
96939687
def test_modularize_instance(self, args):
96949688
if args:
96959689
self.require_pthreads()
@@ -9725,7 +9719,6 @@ def test_modularize_instance(self, args):
97259719

97269720
@no_omit_asm_module_exports('MODULARIZE is not compatible with DECLARE_ASM_MODULE_EXPORTS=0')
97279721
@no_4gb('EMBIND_AOT can\'t lower 4gb')
9728-
@no_strict_js('MODULARIZE is not compatible with STRICT_JS')
97299722
def test_modularize_instance_embind(self):
97309723
self.run_process([EMXX, test_file('modularize_instance_embind.cpp'),
97319724
'-sMODULARIZE=instance',
@@ -9905,7 +9898,6 @@ def setUp(self):
99059898

99069899
# Add DEFAULT_TO_CXX=0
99079900
strict = make_run('strict', cflags=[], settings={'STRICT': 1})
9908-
strict_js = make_run('strict_js', cflags=[], settings={'STRICT_JS': 1})
99099901

99109902
ubsan = make_run('ubsan', cflags=['-fsanitize=undefined', '--profiling'])
99119903
lsan = make_run('lsan', cflags=['-fsanitize=leak', '--profiling'], settings={'ALLOW_MEMORY_GROWTH': 1})

tools/link.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,9 +1147,10 @@ def limit_incoming_module_api():
11471147
elif options.shell_html:
11481148
diagnostics.warning('unused-command-line-argument', '--shell-file ignored when not generating html output')
11491149

1150+
if settings.EXPORT_ES6 or settings.MODULARIZE:
1151+
default_setting('STRICT_JS', 0)
1152+
11501153
if settings.STRICT:
1151-
if not settings.MODULARIZE:
1152-
default_setting('STRICT_JS', 1)
11531154
default_setting('DEFAULT_TO_CXX', 0)
11541155
default_setting('IGNORE_MISSING_MAIN', 0)
11551156
default_setting('AUTO_NATIVE_LIBRARIES', 0)

0 commit comments

Comments
 (0)