Skip to content

Commit ad52571

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. Also remove the closure externs for `assert` so that closure can correctly error out end `assert` is not defined. Helps with #20504
1 parent c188a2c commit ad52571

File tree

3 files changed

+6
-142
lines changed

3 files changed

+6
-142
lines changed

src/closure-externs/node-externs.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ wss._socket.remoteAddress;
5757
*/
5858
wss._socket.remotePort;
5959

60-
/**
61-
* @suppress {duplicate}
62-
*/
63-
var assert;
64-
6560
/**
6661
* @suppress {duplicate}
6762
*/

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

third_party/closure-compiler/node-externs/assert.js

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)