Files
AnyPS5/docs/dev/debt/changes/fix-nkwebkit-js-make-function-single-function.md
ToRaNekandClaude Fable 5.2 48cf6684da fix(libSceNKWebKit): refuse JSObjectMakeFunction text that is not one function
JSObjectMakeFunction joins the name, the parameters and the body into
"(function name(params) {\nbody\n})" and evaluates it. A body such as
"}), sideEffect(), (function () {" closed the function early: the call
ran sideEffect() and returned another function. Parameters, or a name,
could do the same.

JavaScriptCore parses the joined text as a program that must be a
single function whose parameters end where the given ones end, and
raises a SyntaxError otherwise. QuickJS gives no such check, so the
text is compiled, without being run, a few more times: the parameters
alone, the body alone, and with a declaration added after the body
that must land in the function that owns the first parameter.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 08:52:40 +01:00

6 lines
783 B
Markdown

# libSceNKWebKit
## add Functional
- [JSObjectMakeFunction text](../../../core/libs/prx/libSceNKWebKit/src/JscObject.cpp) (libSceNKWebKit) - not checked on a console. The name, the parameters and the body must form one function, as [`UnlinkedFunctionExecutable::fromGlobalCode`](https://github.com/neonmodder123/PS5-WebKit-11.x/blob/80f77e94c63ee7202eec3d4b5b1a021dd89011ba/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp) requires; text that closes the function early is refused with a `SyntaxError` and is not run. QuickJS cannot say where a function ends, so the check compiles the text several times instead, and the message is `Parser error` or the parameters message of JavaScriptCore, not always the one its parser gives. Closes when: compared with a console.