fix: Rewrite inspect(…) to be (probably) side‑effect free#286
Open
ExE-Boss wants to merge 2 commits intoengine262:mainfrom
Open
fix: Rewrite inspect(…) to be (probably) side‑effect free#286ExE-Boss wants to merge 2 commits intoengine262:mainfrom
inspect(…) to be (probably) side‑effect free#286ExE-Boss wants to merge 2 commits intoengine262:mainfrom
Conversation
Jack-Works
requested changes
Apr 24, 2025
| if (isArrayExoticObject(v)) { | ||
| return 'Array'; | ||
| } | ||
| if ('PromiseState' in v) { |
Contributor
There was a problem hiding this comment.
you can use helpers like isPromiseObject
Jack-Works
requested changes
Apr 25, 2025
| if (desc instanceof UndefinedValue) { | ||
| const parent = X(O.GetPrototypeOf()); | ||
| if (parent instanceof NullValue || isProxyExoticObject(parent)) { | ||
| return undefined; |
Contributor
There was a problem hiding this comment.
if parent is null, I think it should return Value.undefined
Contributor
Author
There was a problem hiding this comment.
This intentionally uses undefined (spec value empty) to disambiguate from a data property with a value of Value.undefined.
Contributor
There was a problem hiding this comment.
As I understanding this case is accessing x.a where prototype of x is null, in this case, x.a should be undefined (language value), is that correct?
| const stylizeNoColor: Stylizer = (text) => text; | ||
|
|
||
| function getConstructorName(v: ObjectValue) { | ||
| Assert(!isProxyExoticObject(v)); |
Contributor
There was a problem hiding this comment.
or return undefined for ProxyExoticObject? (same for getNoSideEffects etc)
707b116 to
0b90e51
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This rewrites
inspect(…)in a way which avoids calling proxy traps and property accessors.Other non‑
Proxyimplementations of the object internal methods[[OwnPropertyKeys]],[[GetOwnProperty]], and[[GetPrototypeOf]]seem to be side‑effect free, as far as I can tell.In the process of doing this, I consolidated a lot of the code paths so that own properties are shown for all object types, including functions, primitive boxes,
Promisees,RegExps, andArrays.Partially based on #117.