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

Chakra cannot override RegExp.prototype.exec property #5187

Closed
igor-simoes opened this issue May 17, 2018 · 5 comments
Closed

Chakra cannot override RegExp.prototype.exec property #5187

igor-simoes opened this issue May 17, 2018 · 5 comments

Comments

@igor-simoes
Copy link

igor-simoes commented May 17, 2018

OS: Ubuntu 16.04 x86
Chakra: 1.10.0.0-beta

Step to reproduce:

// RegExp.prototype with overridden exec: Testing ES6 21.2.5.11: 19.b. Let z be ? RegExpExec(splitter, S).
let accesses = [];
let origDescriptor = Object.getOwnPropertyDescriptor(RegExp.prototype, "exec");
let origExec = origDescriptor.value;

Object.defineProperty(RegExp.prototype, "exec", {
    value: function(str) {
        accesses.push("exec");
        return origExec.call(this, str);
    }
});

if (!(accesses == "")) throw new Error("unexpected call to overridden props");
let result = "splitme".split(/it/);
if (!(result == "spl,me")) throw new Error("Unexpec󠁄ted result");
if (!(accesses == "exec,exec,exec,exec,exec,exec")) throw new Error("Property access󠀡es do not match expectation");

Actual results:

Error: Property access󠀡es do not match expectation

Expected results:

Pass without failures

V8, SpiderMonkey and JavascriptCore works as expected.

cinfuzz

@dilijev
Copy link
Contributor

dilijev commented May 30, 2018

Most likely has to do with this property being configurable: false

@dilijev dilijev modified the milestones: vNext, 1.10 May 31, 2018
@fatcerberus
Copy link
Contributor

RegExp.prototype.exec seems to actually be both configurable and writable so I don't think that's the problem:

#/runtime/assert.mjs:33 module()
(ssj) x Object.getOwnPropertyDescriptor(RegExp.prototype, "exec")
prop  __proto__     {...} *3
prop  value         {...} *4
prop  writable      true
prop  enumerable    false
prop  configurable  true

@fatcerberus
Copy link
Contributor

fatcerberus commented Jun 2, 2018

One thing I don’t understand about the repro above is why there should be six calls to .exec? I’d expect two at most, maybe three if it's divide-and-conquer.

@curtisman
Copy link
Contributor

This test case only make sense when RegEx symbols is enabled, because String.prototype.split is not defined based on Regexp.prototype[@@split].

Currently RegEx symbols is not fully implemented. When I tried with the flag -ES6RegExSymbols, I ran into another exception:
SyntaxError: Syntax error in regular expression
at Global code (blah.js:14:1)

The error comes form the implementation of @@split, where it ask for the flags from the passed in regex and got "undefinedy" which seems wrong to me.

@rhuanjl
Copy link
Collaborator

rhuanjl commented Mar 25, 2020

Consolidating as part of #6390

@rhuanjl rhuanjl closed this as completed Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants