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

Tracking issue for new set methods. #4128

Open
7 tasks
nekevss opened this issue Jan 13, 2025 · 5 comments
Open
7 tasks

Tracking issue for new set methods. #4128

nekevss opened this issue Jan 13, 2025 · 5 comments
Assignees
Labels
builtins PRs and Issues related to builtins/intrinsics E-Easy Easy enhancement New feature or request good first issue Good for newcomers

Comments

@nekevss
Copy link
Member

nekevss commented Jan 13, 2025

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 nekevss added enhancement New feature or request good first issue Good for newcomers E-Easy Easy builtins PRs and Issues related to builtins/intrinsics labels Jan 13, 2025
@Hemenguelbindi
Copy link

Hello, I would like to try solving this task!

@nekevss
Copy link
Member Author

nekevss commented Jan 14, 2025

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

@Hemenguelbindi
Copy link

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.

@nekevss
Copy link
Member Author

nekevss commented Jan 19, 2025

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.

Hemenguelbindi added a commit to Hemenguelbindi/boa that referenced this issue Jan 22, 2025
@Hemenguelbindi
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics E-Easy Easy enhancement New feature or request good first issue Good for newcomers
Projects
Status: No status
Development

No branches or pull requests

2 participants