From 555aad552e2ced34a8dfdf35089b14a5532b3a9a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 17 Apr 2024 14:23:06 -0700 Subject: [PATCH] Feedback on #21775 - Add changelog entry - Fix typo in error message - Improve error message --- ChangeLog.md | 4 ++++ src/postamble_modularize.js | 6 +----- test/test_other.py | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5abb6a787fb0..280f0e9bc0fe 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works. 3.1.58 (in development) ----------------------- +- In `-sMODULARIZE` mode, the argument passed into the module constructor is + no longer mutated in place. The expectation is that the module instance will + be available via the constructor return value. Attempting to access methods + on the object passed *into* the constructor will now abort. (#21775) - Enable use of `::` to escape port option separator (#21710) - In multi-threaded builds `--extern-pre-js` and `--extern-post-js` code is now only run on the main thread, and not on each of the workers. (#21750) diff --git a/src/postamble_modularize.js b/src/postamble_modularize.js index bf36db99e359..d8d3a59a4671 100644 --- a/src/postamble_modularize.js +++ b/src/postamble_modularize.js @@ -29,11 +29,7 @@ for (const prop of Object.keys(Module)) { Object.defineProperty(moduleArg, prop, { configurable: true, get() { -#if WASM_ASYNC_COMPILATION - abort(`Access to module property ('${prop}') is no longer possible via the incoming module contructor argument; Instead, use the result of the module promise.`) -#else - abort(`Access to module property ('${prop}') is no longer possible via the module input argument; Instead, use the module constructor return value.`) -#endif + abort(`Access to module property ('${prop}') is no longer possible via the module constructor argument; Instead, use the result of the module constructor.`) } }); } diff --git a/test/test_other.py b/test/test_other.py index af1502dec06f..da6b34b36e42 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -6446,7 +6446,7 @@ def test_modularize_argument_misuse(self): var promise = Module(arg); arg._foo();''') - expected = "Aborted(Access to module property ('_foo') is no longer possible via the incoming module contructor argument; Instead, use the result of the module promise" + expected = "Aborted(Access to module property ('_foo') is no longer possible via the module constructor argument; Instead, use the result of the module constructor" self.do_runf('test.c', expected, assert_returncode=NON_ZERO, emcc_args=['--no-entry', '-sMODULARIZE', '--extern-post-js=post.js']) def test_export_all_3142(self): @@ -6983,7 +6983,7 @@ def test_dlopen_bad_flags(self): out = self.run_js('a.out.js') self.assertContained('invalid mode for dlopen(): Either RTLD_LAZY or RTLD_NOW is required', out) - def test_dlopen_contructors(self): + def test_dlopen_constructors(self): create_file('side.c', r''' #include #include @@ -6998,7 +6998,7 @@ def test_dlopen_contructors(self): __attribute__((constructor)) void ctor(void) { printf("foo address: %p\n", ptr); // Check that relocations have already been applied by the time - // contructor functions run. + // constructor functions run. check_relocations(); printf("done ctor\n"); }