Skip to content

Commit 00b10aa

Browse files
authored
WasmFS: Fix two more trivial closure issues (#19454)
var x = a ? b : abort() confuses closure as it doesn't know that abort is no-return. Move the check to another line.
1 parent 9e979c3 commit 00b10aa

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/library_wasi.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,12 @@ var WasiLibrary = {
519519
FS.isLink(stream.mode) ? {{{ cDefs.__WASI_FILETYPE_SYMBOLIC_LINK }}} :
520520
{{{ cDefs.__WASI_FILETYPE_REGULAR_FILE }}};
521521
#else
522-
// hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
523-
var type = fd == 0 || fd == 1 || fd == 2 ? {{{ cDefs.__WASI_FILETYPE_CHARACTER_DEVICE }}} : abort();
522+
// Hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0. We support at
523+
// least stdin, stdout, stderr in a simple way.
524+
#if ASSERTIONS
525+
assert(fd == 0 || fd == 1 || fd == 2);
526+
#endif
527+
var type = {{{ cDefs.__WASI_FILETYPE_CHARACTER_DEVICE }}};
524528
if (fd == 0) {
525529
rightsBase = {{{ cDefs.__WASI_RIGHTS_FD_READ }}};
526530
} else if (fd == 1 || fd == 2) {

src/library_wasmfs_opfs.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ mergeInto(LibraryManager.library, {
7171
_wasmfs_opfs_init_root_directory: async function(ctx) {
7272
// allocated.length starts off as 1 since 0 is a reserved handle
7373
if (wasmfsOPFSDirectoryHandles.allocated.length == 1) {
74+
// Closure compiler errors on this as it does not recognize the OPFS
75+
// API yet, it seems. Unfortunately an existing annotation for this is in
76+
// the closure compiler codebase, and cannot be overridden in user code
77+
// (it complains on a duplicate type annotation), so just suppress it.
78+
/** @suppress {checkTypes} */
7479
let root = await navigator.storage.getDirectory();
7580
wasmfsOPFSDirectoryHandles.allocated.push(root);
7681
}

0 commit comments

Comments
 (0)