Skip to content

In STRICT mode, only define assert when ASSERTIONS is set #20592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 2, 2023
Merged
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
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works.

3.1.48 (in development)
-----------------------
- The JS `assert` function is no longer available in release builds when
`-sSTRICT` is used. This should only affect users with custom JS library code
which doesn't use `#if ASSERTIONS` guards around their `assert` calls. This
behaviour matches that of `MINIMAL_RUNTIME`. (#20592)
- The minimum version of node required run the compiler was updated from
10.19 to 16.20. This does not effect the node requirements of the generated
JavaScript code. (#20551)
Expand Down
5 changes: 0 additions & 5 deletions src/closure-externs/node-externs.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ wss._socket.remoteAddress;
*/
wss._socket.remotePort;

/**
* @suppress {duplicate}
*/
var assert;

/**
* @suppress {duplicate}
*/
Expand Down
2 changes: 2 additions & 0 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,9 @@ var LibraryPThread = {
PThread.outstandingPromises[pthread_ptr].resolve();
}
#endif
#if ASSERTIONS
assert(worker);
#endif
PThread.returnWorkerToPool(worker);
},

Expand Down
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() when 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 enabled.
/** @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
137 changes: 0 additions & 137 deletions third_party/closure-compiler/node-externs/assert.js

This file was deleted.