Skip to content

Commit

Permalink
In STRICT mode, only define assert when ASSERTIONS is set
Browse files Browse the repository at this point in the history
This matches the behaviour of MINIMAL_RUNTIME, and supports the practice
of not including asserts in release builds.
  • Loading branch information
sbc100 committed Nov 1, 2023
1 parent c188a2c commit fd37de8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ var ABORT = false;
// but only when noExitRuntime is false.
var EXITSTATUS;
#if ASSERTIONS || !STRICT
// In STRICT mode we only define assert() and ASSERTIONS is set. i.e. we don't
// define it at all in release modes. This matches the behaviour of
// MINIMAL_RUNTIME.
// TODO(sbc): Make this the default even without STRICT.
/** @type {function(*, string=)} */
function assert(condition, text) {
if (!condition) {
Expand All @@ -88,6 +93,7 @@ function assert(condition, text) {
#endif
}
}
#endif
#if ASSERTIONS
// We used to include malloc/free by default in the past. Show a helpful error in
Expand Down

0 comments on commit fd37de8

Please sign in to comment.