Wrapping user config in a Proxy breaks RegExps in config
I'm writing a plugin where user config can be a string or RegExp (for filtering). However, when trying to use the RegExp, hardhat crashes with TypeError: RegExp.prototype.global getter called on non-RegExp object. This is because the RegExp isn't actually bound to the original object. This StackOverflow describes the problem and a potential solution.
This issue was marked as stale because it didn't have any activity in the last 30 days. If you think it's still relevant, please leave a comment indicating so. Otherwise, it will be closed in 7 days.
Definitely still relevant, you overzealous stalebot!
@fvictorio
This issue was reproduced in hardhat-proxy-breaks-regexps by adding regExpField.
Fix below and tests are added in PR.
let result = Reflect.get(target, property, receiver);
if (result instanceof Function) {
result = result.bind(target);
}
Please let me know with any questions.