-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[[SourceText]] type problem #1458
Comments
what if we changed the definition of "source text matched by" to include utf-16 encoding |
That would pretty much conflict with other uses of the term "source text". |
I would continue to keep the span of code points in |
@michaelficarra: Interesting. Why do you prefer that alternative? |
Actual UTF-16 encoding won't work because source text can contain unpaired surrogates, but using UTF16Encoding would be fine. |
Right, but note that you can't just pass the whole source text to If we take @michaelficarra's preferred approach ([[SourceText]] is code points), encoding only happens in one spot, so it would be enough to use the phrasing that occurs in a couple other places -- But if we take the other approach ([[SourceText]] is a String), then encoding happens in 26 spots, so it might be worth defining an operation for that phrasing. But then you end up saying:
which is a bit clunky. Instead, it might be better to define an operation that takes the Parse Node as the argument, so you get:
(I have no good suggestion for the name of either operation.) |
If I can get an editorial decision on which way this should go, I'll prepare a PR. |
#1458 (comment) seems simplest to me, and I’d generally prefer to defer to @michaelficarra for toString questions anyways. |
@michaelficarra: I'm curious about |
The spec was inconsistent on whether _F_.[[SourceText]] was a String or a source text (sequence of Unicode code points). This commit picks the latter. Resolves issue tc39#1458.
@jmdyck It's there to prevent |
That would be non-compliant behavior for an ordinary function, so you're talking about an exotic function that elects to have a [[SourceText]] slot, right? |
Any exotic object, yes. |
Also, while we're in the neighborhood, I noticed that async arrow functions don't get their [[SourceText]] set. Is there a reason that wasn't added in #697? |
That’s likely an oversight. A PR to fix that would be great. |
These lines didn't appear in tc39#697. @ljharb says that was likely an oversight: tc39#1458 (comment)
Done. |
These lines didn't appear in tc39#697. `@ljharb` says that was likely an oversight: tc39#1458 (comment)
The spec was inconsistent on whether _F_.[[SourceText]] was a String or a source text (sequence of Unicode code points). This commit picks the latter. Resolves issue tc39#1458.
The spec was inconsistent on whether _F_.[[SourceText]] was a String or a source text (sequence of Unicode code points). This commit picks the latter. Resolves issue tc39#1458.
The spec was inconsistent on whether _F_.[[SourceText]] was a String or a source text (sequence of Unicode code points). This commit picks the latter. Resolves issue tc39#1458.
From PR #697, each ECMAScript function object now has a
[[SourceText]]
internal slot. Table 27 says that its type is String. However, most of the steps where it is set are of the form:and source text is "a sequence of [Unicode] code points", which is not a String.
Presumably,
[[SourceText]]
should get the result of UTF-16 encoding the source text.(Alternatively, you could defer the UTF-16 encoding to the point where
[[SourceText]]
is used, inFunction.prototype.toString
. So the type of[[SourceText]]
would be something like "Unicode code points". But then you'd have to UTF-16 decode_sourceText_
inCreateDynamicFunction
, which seems silly.)The text was updated successfully, but these errors were encountered: