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

feat(ecmascript): Implement Annex-B string prototype methods #544

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

Conversation

eliassjogreen
Copy link
Contributor

I also added some feature flags for including parts of or the whole of annex-b. Made them on-by-default, but might make more sense for them to be off?

I also added some feature flags for including parts of or the whole of annex-b. Made them on-by-default, but might make more sense for them to be off?
@eliassjogreen eliassjogreen force-pushed the feat/ecmascript-annex-b-string-methods branch from f22b3ff to 61ce8a8 Compare January 21, 2025 15:20
@eliassjogreen
Copy link
Contributor Author

There are no expectations updated because we have turned off Annex B in the test runner, I ran it locally and it passed the string expectations, but I don't suppose we want to turn it on for the whole engine.

Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me, but let's change the function identities to match what the spec expects since it should be fairly easy to do.

We could also add the feature flag to the tests build and (eventually at least) turn on Annex B testing, but indeed let's not turn it on by default for the cli build. Don't want that whole mess.

We could also make PR to https://github.com/test262-fyi/test262.fyi/blob/main/scripts/engines/nova.sh to run with the Annex B feature flags.

#[cfg(feature = "annex-b-string")]
struct StringPrototypeTrimLeft;
#[cfg(feature = "annex-b-string")]
impl Builtin for StringPrototypeTrimLeft {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (blocking, but not very strongly): The spec's terminology for TrimLeft and TrimRight is

The initial value of the "trimLeft" property is %String.prototype.trimStart%, defined in 22.1.3.34.

ie. it's not just another function that does the same thing but it's actually the same function object. You should impl BuiltinIntrinsic for StringPrototypeTrimStart and make StringPrototypeTrimLeft a reference to that. See f.ex. how ArrayPrototypeValues and how we use with_property to generate array.prototype[Symbol.Iterator].

/// ECMAScript language value) and returns either a normal completion
/// containing a String or a throw completion.
#[cfg(feature = "annex-b-string")]
fn create_html<'gc>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: This is nice <3

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.

2 participants