Skip to content

[FS] Fix Closure compiler arity and type warnings with -sEXPORT_ES6 - #27749

Open
sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:fix-closure-fs-es6
Open

sbc100 wants to merge 1 commit into
emscripten-core:mainfrom
sbc100:fix-closure-fs-es6

Conversation

@sbc100

@sbc100 sbc100 commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

When -sEXPORT_ES6 is enabled, Closure Compiler compiles output in ES module mode (--chunk_output_type ES_MODULES), which enforces strict arity checks (JSC_WRONG_ARGUMENT_COUNT) and object property type checks (JSC_TYPE_MISMATCH) that are otherwise silently ignored in traditional global script mode.

Give optional parameters default values (= undefined or appropriate defaults like dontFollow = false), initialize nameTable: [] instead of null, and remove surplus arguments at call sites in libsyscall.js and libnodefs.js.

See google/closure-compiler#4344

Fixes: #27747

@sbc100
sbc100 force-pushed the fix-closure-fs-es6 branch 2 times, most recently from a41a5e7 to 5e9bd48 Compare September 18, 2026 22:41
@sbc100
sbc100 requested a review from kripken September 18, 2026 22:43
When `-sEXPORT_ES6` is enabled, Closure Compiler compiles output in
ES module mode (`--chunk_output_type ES_MODULES`), which enforces strict
arity checks (`JSC_WRONG_ARGUMENT_COUNT`) and object property type
checks (`JSC_TYPE_MISMATCH`) that are otherwise silently ignored in
traditional global script mode.

Give optional parameters default values (`= undefined` or appropriate
defaults like `dontFollow = false`), initialize `nameTable: []` instead
of `null`, and remove surplus arguments at call sites in `libsyscall.js`
and `libnodefs.js`.

Fixes: emscripten-core#27747
@sbc100
sbc100 enabled auto-merge (squash) September 18, 2026 22:47
Comment thread src/lib/libfs.js
return FS.lookup(parent, name);
},
createNode(parent, name, mode, rdev) {
createNode(parent, name, mode, rdev = undefined) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This increases code size, doesn't it? Or does it get optimized out somehow?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think overall this change is a slight codesize win. I think because closure can eliminate these

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Closure JSC_WRONG_ARGUMENT_COUNT against the FS runtime with -sEXPORT_ES6 on 6.0.x (fatal under -Wall -Werror)

2 participants