mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 01:08:56 +00:00
LibJS: Support string literal expressions in nullish object exceptions
This commit is contained in:
parent
e7f2af6ff4
commit
e3ef849838
Notes:
sideshowbarker
2024-07-16 23:54:15 +09:00
Author: https://github.com/trflynn89
Commit: e3ef849838
Pull-request: https://github.com/SerenityOS/serenity/pull/23802
2 changed files with 19 additions and 0 deletions
|
@ -458,6 +458,11 @@ static Optional<ByteString> expression_identifier(Expression const& expression)
|
|||
return literal.value().to_string_without_side_effects().to_byte_string();
|
||||
}
|
||||
|
||||
if (expression.is_string_literal()) {
|
||||
auto const& literal = static_cast<StringLiteral const&>(expression);
|
||||
return ByteString::formatted("'{}'", literal.value());
|
||||
}
|
||||
|
||||
if (expression.is_member_expression()) {
|
||||
auto const& member_expression = static_cast<MemberExpression const&>(expression);
|
||||
StringBuilder builder;
|
||||
|
|
|
@ -37,6 +37,20 @@ test("null/undefined object key", () => {
|
|||
TypeError,
|
||||
`Cannot access property "baz" on ${value} object "foo.bar"`
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
foo["bar"].baz;
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
`Cannot access property "baz" on ${value} object "foo['bar']"`
|
||||
);
|
||||
|
||||
expect(() => {
|
||||
foo["bar"].baz = 1;
|
||||
}).toThrowWithMessage(
|
||||
TypeError,
|
||||
`Cannot access property "baz" on ${value} object "foo['bar']"`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue