Skip to content

Commit 1348795

Browse files
committed
Fix webidl_binder so it can't handle missing assert function
This can happen when ASSERTIONS is not set and we are in STRICT mode or MINIMAL_RUNTIME mode. See emscripten-core#20592
1 parent 3de1b90 commit 1348795

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

test/test_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7669,6 +7669,7 @@ def test_embind_no_rtti_followed_by_rtti(self):
76697669
def test_webidl(self, mode, allow_memory_growth):
76707670
self.uses_es6 = True
76717671
self.set_setting('WASM_ASYNC_COMPILATION', 0)
7672+
self.set_setting('STRICT')
76727673
if self.maybe_closure():
76737674
# avoid closure minified names competing with our test code in the global name space
76747675
self.set_setting('MODULARIZE')

test/webidl/post.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ try {
239239
} catch (e) {}
240240

241241
try {
242-
s = new TheModule.StringUser('abc', 1);
242+
var s = new TheModule.StringUser('abc', 1);
243243
s.Print(123, null); // Expects a string or a wrapped pointer
244244
} catch (e) {}
245245

tools/webidl_binder.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ def build_constructor(name):
133133
mid_js += build_constructor('WrapperObject')
134134

135135
mid_js += ['''
136+
/*
137+
* For now, the webidl-generated code unconditionally depends on the `assert` function,
138+
* but there are certain build modes where emscripten does not define this.
139+
* TODO(sbc): Make the usage of assert conditional.
140+
*/
141+
if (typeof assert == "undefined") {
142+
assert = (cond) => {}
143+
}
144+
136145
/** @suppress {duplicate} (TODO: avoid emitting this multiple times, it is redundant)
137146
@param {*=} __class__ */
138147
function getCache(__class__) {

0 commit comments

Comments
 (0)