diff options
author | Linus Groh <mail@linusgroh.de> | 2022-12-09 23:55:28 +0000 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-12-10 11:23:23 +0000 |
commit | 1fe7984160d8837664373c46d144dee67282d07f (patch) | |
tree | 7d0ecfdf95cabde92e90dbd7f8adfe576c321d1c | |
parent | b11135cbc28e0c326fb804380b2d01ce1db3f5b4 (diff) | |
download | serenity-1fe7984160d8837664373c46d144dee67282d07f.zip |
LibJS: Add spec comments to Value::is_regexp()
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index 3dcbc53722..cd38627cf0 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -277,13 +277,19 @@ bool Value::is_constructor() const // 7.2.8 IsRegExp ( argument ), https://tc39.es/ecma262/#sec-isregexp ThrowCompletionOr<bool> Value::is_regexp(VM& vm) const { + // 1. If argument is not an Object, return false. if (!is_object()) return false; + // 2. Let matcher be ? Get(argument, @@match). auto matcher = TRY(as_object().get(*vm.well_known_symbol_match())); + + // 3. If matcher is not undefined, return ToBoolean(matcher). if (!matcher.is_undefined()) return matcher.to_boolean(); + // 4. If argument has a [[RegExpMatcher]] internal slot, return true. + // 5. Return false. return is<RegExpObject>(as_object()); } |