-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add missing ToString for assertion value in dynamic import() Runtime Semantics #106
Conversation
Enforcing a type is a good change, but i'm wondering what we should do for nested objects since that would technically allow them? |
I think it's good to start with keeping dynamic import on the same level as static import as far as what it exposes. If we have hosts which want to take more complex objects as import assertion parameters, we should work out a syntax that works for static import as well. |
@littledan I was thinking about the consistency between static and dynamic import. If a host relies on nested object we should make it work the same in both cases, but currently with this change it only would work in the dynamic case |
@xtuc The static case is covered by not having any syntax for a nested object. |
yes, my understanding is that dynamic import will possibility call ToString on a nested object, whereas static import would fail to parse. |
Oh, I see. I guess it makes sense to simply check the type, rather than calling ToString, for future-proofing. |
Lifting restriction is easier than adding them later, I would suggest to make dynamic and static imports consistent and we can change the syntax over time to allow more types. How does that sound? |
That sounds good to me; I just didn't understand what you were suggesting at first. |
No worries, i was being unclear. |
…edAssertions check after type check.
@xtuc @littledan Thanks, I agree that it makes more sense to keep this consistent with the static syntax by restricting to only strings. I've updated the PR to do that. I also moved the import("./foo", { assert: { maybeSupportedAssertion: { isAString: false } }); This should probably fail regardless of whether the host supports maybeSupportedAssertion or not, so the supported assertions check needs to be after we check the type of the value. |
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.
Thanks for the update
Just noticed I never landed this; doing so now... |
The Keys and Values in a ModuleRequest's [[Assertions]] list are supposed to be Strings. But, in the Runtime Semantics for the version of dynamic import() that takes an assertions argument, the
value
obtained fromassertionsObj
for a given assertion key inside the loop might not necessarily be a string.This change adds the needed
ToString()
conversion before using thevalue
in the assertions list.