Skip to content

Appropriate error for exceeding an implementation limit for table or memory size #879

Closed
@lars-t-hansen

Description

@lars-t-hansen

At the moment, the Wasm JS API spec uses "[EnforceRange] unsigned long" for a number of parameters to API methods. For values outside the [0..2^31-1] range, a TypeError is thrown on function entry. This differs from our past behavior, where we would throw RangeError, but it's what WebIDL requires.

At the same time, we still throw RangeError if maximum is present and maximum < initial.

The question is what we should do if the initial or max value exceeds the maximum allowable by the implementation. For example, for a Table, the max is 1e7 elements. Firefox has been throwing RangeError here, but to a large extent this is as a side effect of using the same logic for checking for 1e7 as it would use to check for 2^32-1.

As I am updating Firefox to be WebIDL-compliant, the fallout would be that we throw TypeError for when we exceed 1e7 as well, that is, we will effectively assume that the value of the parameter is restricted to [0..1e7]. However I could choose to use TypeError only for the checks against the parameter type, but use RangeError when we exceed the implementation limit.

Does anyone have opinions about this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions