Skip to content

Commit 75aaf0b

Browse files
committed
In STRICT mode, only define assert when ASSERTIONS is set
This matches the behaviour of MINIMAL_RUNTIME, and supports the practice of not including asserts in release builds.
1 parent c188a2c commit 75aaf0b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/preamble.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ var ABORT = false;
7575
// but only when noExitRuntime is false.
7676
var EXITSTATUS;
7777

78+
#if ASSERTIONS || !STRICT
79+
// In STRICT mode, we only define assert() when ASSERTIONS is set. i.e. we
80+
// don't define it at all in release modes. This matches the behaviour of
81+
// MINIMAL_RUNTIME.
82+
// TODO(sbc): Make this the default even without STRICT enabled.
7883
/** @type {function(*, string=)} */
7984
function assert(condition, text) {
8085
if (!condition) {
@@ -88,6 +93,7 @@ function assert(condition, text) {
8893
#endif
8994
}
9095
}
96+
#endif
9197

9298
#if ASSERTIONS
9399
// We used to include malloc/free by default in the past. Show a helpful error in

0 commit comments

Comments
 (0)