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

SetMutableBinding and ImportBindings #2639

Open
jmdyck opened this issue Jan 25, 2022 · 4 comments
Open

SetMutableBinding and ImportBindings #2639

jmdyck opened this issue Jan 25, 2022 · 4 comments
Labels

Comments

@jmdyck
Copy link
Collaborator

jmdyck commented Jan 25, 2022

This concerns:

  • immutable indirect bindings (IIB) created by CreateImportBinding for module Environment Records, and
  • the SetMutableBinding method for declarative Environment Records (which includes module Environment Records).

Currently, SetMutableBinding doesn't explicitly say how it handles an IIB. Mostly, it doesn't need to be explicit:

  • an IIB is initialized when created, so the 'has not yet been initialized' step doesn't apply, and
  • an IIB is immutable, so the 'is a mutable binding' step doesn't apply.

So it's clear that SetMutableBinding won't change the IIB, the only question is whether to throw a *TypeError* or not. Which depends on:

  • whether an IIB is a strict binding, or
  • whether the passed-in _S_ is *true*.

Now it definitely isn't stated that an IIB is a strict binding, but it might be intended. And I think the passed-in _S_ is always *true* for any case involving an IIB (i.e., for a module Environment Record), but I'm not completely sure.

So: does SetMutableBinding always throw a *TypeError* when the binding in question is an IIB?

@jmdyck
Copy link
Collaborator Author

jmdyck commented Jan 25, 2022

(The answer may affect how I finally resolve PR #2288.)

@michaelficarra
Copy link
Member

I don't think there's anything preventing us from saying it's strict, so that seems the preferable option. In which case, a TypeError should be thrown.

This should be testable, right? Can we see what implementations do here?

@jmdyck
Copy link
Collaborator Author

jmdyck commented Nov 7, 2022

This should be testable, right? Can we see what implementations do here?

If the passed-in _S_ is *true*, a TypeError should be thrown regardless of the strictness of an IIB. So the most interesting test would cause the passed-in _S_ to be *false*, because then the results would reveal whether implementations treat an IIB as a strict binding. However, I don't know if it's possible to construct such a test.

@michaelficarra
Copy link
Member

Ah, since direct evals in strict mode code are also strict, I don't know how to exercise this either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants