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

Missing coverage for content type check in TypedArraySpeciesCreate #3066

Open
Lubrsi opened this issue Jul 19, 2021 · 0 comments
Open

Missing coverage for content type check in TypedArraySpeciesCreate #3066

Lubrsi opened this issue Jul 19, 2021 · 0 comments

Comments

@Lubrsi
Copy link

Lubrsi commented Jul 19, 2021

In TypedArraySpeciesCreate, it says:

6. If result.[[ContentType]] ≠ exemplar.[[ContentType]], throw a TypeError exception.

For example, this should print Checked content type instead of Missing content type check:

class TypedArray extends Uint32Array {
    static get [Symbol.species]() {
        return BigUint64Array;
    }
}

try
{
    new TypedArray().filter(() => {});
    console.log("Missing content type check");
}
catch
{
    console.log("Checked content type");
}

This is because Uint32Array is of type Number, whereas BigUint64Array is of type BigInt, which should throw as per the specification above.

However, there are no test cases for this. Both V8 and SpiderMonkey print Missing content type check, whereas JavaScriptCore throws and thus prints Checked content type:

    if (@typedArrayContentType(this) !== @typedArrayContentType(result))
        @throwTypeError("TypedArray.prototype.filter constructed typed array of different content type from |this|");

Source: https://github.com/WebKit/WebKit/blob/075023a72c83201aca70a9c2238a5886300f501b/Source/JavaScriptCore/builtins/TypedArrayPrototype.js#L370-L371

Note that this should also happen for map, slice and subarray, I just happened to use filter for the example.

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

No branches or pull requests

1 participant