-
-
Notifications
You must be signed in to change notification settings - Fork 602
Fix accessing properties defined by a bound function #2299
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -419,6 +419,8 @@ private static JsValue UnwrapFromGetter(PropertyDescriptor desc, JsValue thisObj | |||||||||||||||||||||||||||||||||||||||
| return Undefined; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| if (getter is Function.BindFunction bindFunction) return bindFunction._engine.Call(bindFunction, thisObject); | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| var functionInstance = (Function.Function) getter; | ||||||||||||||||||||||||||||||||||||||||
| return functionInstance._engine.Call(functionInstance, thisObject); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+422
to
425
|
||||||||||||||||||||||||||||||||||||||||
| if (getter is Function.BindFunction bindFunction) return bindFunction._engine.Call(bindFunction, thisObject); | |
| var functionInstance = (Function.Function) getter; | |
| return functionInstance._engine.Call(functionInstance, thisObject); | |
| if (getter is Function.BindFunction bindFunction) return bindFunction._engine.Call(bindFunction, thisObject, Arguments.Empty); | |
| var functionInstance = (Function.Function) getter; | |
| return functionInstance._engine.Call(functionInstance, thisObject, Arguments.Empty); |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This accessor invocation path is still tightly coupled to specific concrete function types (BindFunction vs Function.Function) and will continue to throw InvalidCastException for any other callable getter that isn’t Function.Function. Elsewhere in this file (e.g., TryGetValue) getters are treated as ICallable.
Consider switching UnwrapFromGetter to use IsCallable/ICallable (and then invoking via Engine.Call) so all valid callable getter types are supported without adding more special-cases over time.
| if (getter is Function.BindFunction bindFunction) return bindFunction._engine.Call(bindFunction, thisObject); | |
| var functionInstance = (Function.Function) getter; | |
| return functionInstance._engine.Call(functionInstance, thisObject); | |
| if (!getter.IsCallable()) | |
| { | |
| return Undefined; | |
| } | |
| var callable = (ICallable) getter; | |
| return callable.Call(thisObject, Arguments.Empty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change fixes a specific regression scenario (accessor getter is a bound function), but the PR doesn’t add a regression test to ensure it stays fixed. Please add a test that defines an accessor via
Object.defineProperty(..., { get: someFn.bind(...) })and asserts the property access returns the expected value (and ideally thatarguments.lengthinside the getter remains 0).