Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// before the code. Then that object will be used in the code, and you
// can continue to use Module afterwards as well.
#if MODULARIZE
var Module = moduleArg;
var Module = Object.assign({}, moduleArg);
#elif USE_CLOSURE_COMPILER
// if (!Module)` is crucial for Closure Compiler here as it will otherwise replace every `Module` occurrence with a string
var /** @type {{
Expand Down
13 changes: 13 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -6770,6 +6770,19 @@ def test_modularize_sync_compilation(self):
after
''', self.run_js('a.out.js'))

def test_modularize_argument_misuse(self):
create_file('test.c', '''
#include <emscripten.h>
EMSCRIPTEN_KEEPALIVE int foo() { return 42; }''')

create_file('post.js', r'''
var arg = { bar: 1 };
var promise = Module(arg);
arg._foo();''')

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):
create_file('src.cpp', r'''
typedef unsigned int Bit32u;
Expand Down
Loading