Skip to content
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

Always evaluate on [[GetOwnProperty]] of a string #49

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nicolo-ribaudo
Copy link
Member

Since #33, the [[Get]] internal method of namespace objects was updated to do:

  • if the property key is a symbol, do an ordinary get and return.
  • if the namespace is deferred, evaluate it
  • if the property key is not a known export, return undefined
  • get the export value and return it

I was assuming that [[GetOwnProperty]] would do the same, since it internally uses [[Get]]. However, what it did was:

  • if the property key is a symbol, do an ordinary getOwnProperty and return.
  • if the property key is not a known export, return undefined
  • call [[Get]]
  • return a property descriptor

Which means that, even if it calls [[Get]], its effect is still gated on the existence of the property. For consistency, this PR triggers evaluation in [[GetOwnProperty]] before checking whether the property is a known export or not.

@Jack-Works
Copy link
Member

can we only evaluate iff the key is an export name? I don't want to see things like if(mod.__esModule) let the optimization fails

@nicolo-ribaudo
Copy link
Member Author

@Jack-Works I'm going to present that as an option. Although, mod.__esModule is checked in transpiled code and thus tools can special-case it.

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.

3 participants