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

Implement Set.union #212

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Implement Set.union #212

wants to merge 11 commits into from

Conversation

frehner
Copy link

@frehner frehner commented Apr 12, 2023

Hello! First time contributor here, so feel free to suggest anything and everything to me. ❤️


I am in the process of looking at writing some test262 tests for the new Set Methods (currently at Stage 3), and subsequently came across engine262 as a place where I could validate the tests.

With that goal in mind, I thought I could start by writing the implementation of just union, to get an idea of how everything works and figure it out. That said, I'm sure there's stuff here I've done wrong and would love to get feedback on it.

Copy link
Member

@devsnek devsnek left a comment

Choose a reason for hiding this comment

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

these two things jumped out at me. dunno if they are the cause or not.

src/intrinsics/SetPrototype.mjs Outdated Show resolved Hide resolved
src/intrinsics/SetPrototype.mjs Outdated Show resolved Hide resolved
frehner and others added 2 commits April 11, 2023 18:25
Co-authored-by: snek <me@gus.host>
Co-authored-by: snek <me@gus.host>
@frehner
Copy link
Author

frehner commented Apr 12, 2023

That appears to have done it, thank you!

frehner and others added 3 commits April 17, 2023 15:28
Also add a new message, as I couldn't seem to find one that matched, but I'm unsure if I missed it or not.
@frehner frehner marked this pull request as ready for review May 22, 2023 20:12
@frehner
Copy link
Author

frehner commented May 22, 2023

I'm marking tc39/test262#3816 as ready for review, and this implementation should pass all the tests there. 👍

@@ -172,6 +232,7 @@ export function bootstrapSetPrototype(realmRec) {
['has', SetProto_has, 1],
['size', [SetProto_sizeGetter]],
['values', SetProto_values, 0],
['union', SetProto_union, 1],
Copy link
Author

Choose a reason for hiding this comment

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

I'm actually fairly unsure what the number here means, so please double check this. :)

Copy link
Member

@devsnek devsnek May 22, 2023

Choose a reason for hiding this comment

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

its the initial "length" property of the function. based on this in the spec:

Every built-in function object, including constructors, has a "length" property whose value is a non-negative integral Number. Unless otherwise specified, this value is the number of required parameters shown in the subclause heading for the function description. Optional parameters and rest parameters are not included in the parameter count.

[NOTE 2] For example, the function object that is the initial value of the "map" property of the Array prototype object is described under the subclause heading «Array.prototype.map (callbackFn [ , thisArg])» which shows the two named arguments callbackFn and thisArg, the latter being optional; therefore the value of the "length" property of that function object is 1𝔽.

@@ -135,6 +135,7 @@ export const RegExpExecNotObject = (o) => `${i(o)} is not object or null`;
export const ResolutionNullOrAmbiguous = (r, n, m) => (r === null
? `Could not resolve import ${i(n)} from ${m.HostDefined.specifier}`
: `Star export ${i(n)} from ${m.HostDefined.specifier} is ambiguous`);
export const SizeIsNaN = () => 'size property must not be undefined, as it will be NaN';
Copy link
Author

Choose a reason for hiding this comment

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

There doesn't appear to be an existing error for this situation, so I added this here. That said, I'm very open to changes/suggestions on this part.

I'm also unsure if there's some sort of process I need to go through to get the linter working with this new error?

Copy link
Member

Choose a reason for hiding this comment

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

all you need to do for the linter is run the build script.

@frehner
Copy link
Author

frehner commented Nov 15, 2023

FYI, the corresponding PR in test262 has been merged. 🎉

This PR should still pass all the tests, but I won't have the chance to verify that for a bit.

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.

None yet

3 participants