boa icon indicating copy to clipboard operation
boa copied to clipboard

Tracking issue for new `set` methods.

Open nekevss opened this issue 1 year ago • 6 comments

The set methods proposal has landed in the specification. These methods need to be implemented for our conformance.

Fore reference, the archived proposal repository can be found here. Although, the methods are also currently in the ECMAScript spec.

Methods that need to be implemented

nekevss avatar Jan 13 '25 17:01 nekevss

Hello, I would like to try solving this task!

Hemenguelbindi avatar Jan 14 '25 08:01 Hemenguelbindi

Sure! Assigned it to you. Feel free to reach out if you have any questions :smile:

nekevss avatar Jan 14 '25 14:01 nekevss

Hello, I have encountered an issue with two methods: Set.prototype.intersection(other) and Set.prototype.difference(other). When I ask it to check the following: ```rust fn difference_empty(){ run_test_actions([ TestAction::run(indoc! {r#" let setA = new Set([1, 3, 5, 7, 9]); let setB = new Set([]); "#}),

    TestAction::assert_with_op("setA.difference(setB)", |v, _| {
        v.display().to_string() == "Set { 1, 3, 5, 7, 9 }"
    }),
    TestAction::assert_with_op("setB.difference(setA)", |v, _| {
        v.display().to_string() == "Set {  }"
    }),
]);

}``` And specifically, the check fails when we try to perform one of these operations on a non-empty set. Perhaps I wrote the test incorrectly, missed some logic, or didn't fully understand how to correctly return the result. If you could point out where I got stuck or what I did wrong, it would greatly help me in my further work.

Hemenguelbindi avatar Jan 18 '25 22:01 Hemenguelbindi

I took a look at the branch that you're working on, and I think the implementations may be a bit optimistic at current for the specification, especially in these two methods.

My recommendation would be to copy and paste the specification steps and then work through them individually with a Boa like internal (if you'd like a good example of this in the engine, I'd recommend many of the Array methods).

The specification has a couple of sneaky user land calls that are worked into the specification that means following the steps, especially in certain locations may be fairly important.

For instance, test262 has a test for a set-like object and set-like class.

Also, if it wasn't for the userland calls, I'd recommend taking a look at IndexSet docs as it already has implementations of the methods that might be implementable on OrderedSet.

Also, an early comment would be: these are methods, so they should be added to the BuiltinBuilder as .method(Self::difference, "difference", 1) over defining them as properties.

nekevss avatar Jan 19 '25 02:01 nekevss

Hello, i am done this tasks and create pull requests #4145

Hemenguelbindi avatar Jan 26 '25 11:01 Hemenguelbindi

Completed and all tests are passing on the conformance page.

nekevss avatar Jun 03 '25 19:06 nekevss