Accessing `RegExp.prototype.flags` directly should throw

RESOLVED INVALID

Status

()

RESOLVED INVALID
4 years ago
2 years ago

People

(Reporter: mathias, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
Since bug 1108467 the following test was added to the codebase:

    assertEq(RegExp.prototype.flags, "");

However, `RegExp.prototype.flags` should throw since it accesses `RegExp.prototype.global` which throws in step 3 of its algorithm (since `R = RegExp.prototype` in this situation):

    3. If R does not have an [[OriginalFlags]] internal slot throw a TypeError exception.

Consider removing this broken test and behavior.
(Reporter)

Updated

4 years ago
See Also: → bug 1108467

Comment 1

4 years ago
Oh, indeed!
(Reporter)

Comment 2

4 years ago
Since none of the major ECMAScript engines seem to implement the part of the algorithm described above, maybe the spec should be changed. I’ve filed https://bugs.ecmascript.org/show_bug.cgi?id=3432.

Updated

3 years ago
Depends on: 1192038

Comment 3

2 years ago
A recent amendment of the spec (https://github.com/tc39/ecma262/pull/511) made this bug invalid: now RegExp.prototype.flags should produce "".
Claude is right.
Status: NEW → RESOLVED
Last Resolved: 2 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.