TypeError: can't supply flags when constructing one RegExp from another $:2:128894
TypeError: I10C.PreLocationContextProxy(...).locat1on is undefine $:2:3419
ReferenceError: locat1on is not defined $:2:105812
Ad https://forum.palemoon.org/viewtopic.php?f=3&t=18537
https://www.msn.com/pt-pt/?ocid=mailsignout
- Does not display the pictures
- Throws an errors in Browser Console:
```
TypeError: can't supply flags when constructing one RegExp from another $:2:128894
TypeError: I10C.PreLocationContextProxy(...).locat1on is undefine $:2:3419
ReferenceError: locat1on is not defined $:2:105812
```
An example (for Scratchpad):
``` javascript
function assertEq(a, b) {
if (a == b) {
console.log(a + ", " + b + ": true");
} else {
console.log(a + ", " + b + ": false");
}
}
function assertThrowsInstanceOf(a, b) {
try {
a();
console.log(b + ": false");
} catch (e) {
console.log(e + " (" + b + ")?: true");
}
}
assertEq(RegExp(/foo/my).flags, "my");
assertEq(RegExp(/foo/, "gi").flags, "gi");
assertEq(RegExp(/foo/my, "gi").flags, "gi");
assertEq(RegExp(/foo/my, "").flags, "");
assertEq(RegExp(/foo/my, undefined).flags, "my");
assertThrowsInstanceOf(() => RegExp(/foo/my, null), "SyntaxError");
assertThrowsInstanceOf(() => RegExp(/foo/my, "foo"), "SyntaxError");
assertEq(/a/.compile("b", "gi").flags, "gi");
assertEq(/a/.compile(/b/my).flags, "my");
assertEq(/a/.compile(/b/my, undefined).flags, "my");
assertThrowsInstanceOf(() => /a/.compile(/b/my, "gi"), "TypeError");
assertThrowsInstanceOf(() => /a/.compile(/b/my, ""), "TypeError");
assertThrowsInstanceOf(() => /a/.compile(/b/my, null), "TypeError");
assertThrowsInstanceOf(() => /a/.compile(/b/my, "foo"), "TypeError");
```
Actual results:
```
"my, my: true"
"TypeError: can't supply flags when constructing one RegExp from another"
```
Expected results:
```
"my, my: true"
"gi, gi: true"
", : true"
"my, my: true"
"SyntaxError: invalid regular expression flag n (SyntaxError)?: true"
"SyntaxError: invalid regular expression flag f (SyntaxError)?: true"
"gi, gi: true"
"my, my: true"
"TypeError: can't supply flags when constructing one RegExp from another (TypeError)?: true"
```
``` javascript
new RegExp('ab+c', 'i');
new RegExp(/ab+c/, 'i');
```
A pattern can have two values/types (a string/regular expression).
See:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Description
~~I don't see it in the specification but this is perhaps my fault.~~
http://www.ecma-international.org/ecma-262/6.0/#sec-regexp-pattern-flags
This problem solves - RegExp(RegExp object, flags) no longer throws - [bug 1108949](https://bugzilla.mozilla.org/show_bug.cgi?id=1108949)
Some test/personal branch/commit (with the expected result):
[tree@js_regexp_pattern_1](https://github.com/janekptacijarabaci/Pale-Moon/commit/3e7a8f4d40ec9069ddc3f0cbd5d11fdaa827f255)
If NewTarget is not undefined, let newTarget be NewTarget.
Else,
a) Let newTarget be the active function object.
b) If patternIsRegExp is true and flags is undefined, then
i) Let patternConstructor be Get(pattern, “constructor”).
ii) ReturnIfAbrupt(patternConstructor).
iii) If SameValue(newTarget, patternConstructor) is true, return pattern.
If Type(pattern) is Object and pattern has a RegExpMatcher internal slot, then
a) Let P be the value of pattern’s OriginalSource internal slot.
a) If flags is undefined, let F be the value of pattern’s OriginalFlags internal slot.
a) Else, let F be flags.
Else if patternIsRegExp is true, then
a) Let P be Get(pattern, “source”).
b) ReturnIfAbrupt(P).
c) If flags is undefined, then
i) Let F be Get(pattern, “flags”).
ii) ReturnIfAbrupt(F).
d) Else, let F be flags.
Else,
a) Let P be pattern.
b) Let F be flags.
Let O be RegExpAlloc(newTarget).
ReturnIfAbrupt(O).
Return RegExpInitialize(O, P, F).
> Is this actually in ES6?
IMHO yes.
https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.1
vs.
http://www.ecma-international.org/ecma-262/6.0/#sec-regexp-pattern-flags
> RegExp ( pattern, flags )
> The following steps are taken:
> 1. Let patternIsRegExp be IsRegExp(pattern).
> 2. ReturnIfAbrupt(patternIsRegExp).
> 3. If NewTarget is not undefined, let newTarget be NewTarget.
> 4. Else,
> a) Let newTarget be the active function object.
> b) If patternIsRegExp is true and flags is undefined, then
> i) Let patternConstructor be Get(pattern, "constructor").
> ii) ReturnIfAbrupt(patternConstructor).
> iii) If SameValue(newTarget, patternConstructor) is true, return pattern.
> 5. If Type(pattern) is Object and pattern has a [[RegExpMatcher]] internal slot, then
> a) Let P be the value of pattern’s [[OriginalSource]] internal slot.
> a) If flags is undefined, let F be the value of pattern’s [[OriginalFlags]] internal slot.
> a) Else, let F be flags.
> 6. Else if patternIsRegExp is true, then
> a) Let P be Get(pattern, "source").
> b) ReturnIfAbrupt(P).
> c) If flags is undefined, then
> i) Let F be Get(pattern, "flags").
> ii) ReturnIfAbrupt(F).
> d) Else, let F be flags.
> 7. Else,
> a) Let P be pattern.
> b) Let F be flags.
> 8. Let O be RegExpAlloc(newTarget).
> 9. ReturnIfAbrupt(O).
> 10. Return RegExpInitialize(O, P, F).
Ad https://forum.palemoon.org/viewtopic.php?f=3&t=18537
https://www.msn.com/pt-pt/?ocid=mailsignout
An example (for Scratchpad):
Actual results:
Expected results:
A pattern can have two values/types (a string/regular expression).
See:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#Description
I don’t see it in the specification but this is perhaps my fault.http://www.ecma-international.org/ecma-262/6.0/#sec-regexp-pattern-flags
This problem solves - RegExp(RegExp object, flags) no longer throws - bug 1108949
Some test/personal branch/commit (with the expected result):
tree@js_regexp_pattern_1
Is this actually in ES6? because according to ES5 this has to throw.
IMHO yes.
https://www.ecma-international.org/ecma-262/5.1/#sec-15.10.1
vs.
http://www.ecma-international.org/ecma-262/6.0/#sec-regexp-pattern-flags
Thanks
Fixed. Verified.
https://forum.palemoon.org/viewtopic.php?f=3&t=18537&p=136523#p136523