mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 16:18:12 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -256,7 +256,7 @@ public:
|
|||
private:
|
||||
void throw_identifier_declared(FlyString const& name, NonnullRefPtr<Declaration> const& declaration)
|
||||
{
|
||||
m_parser.syntax_error(String::formatted("Identifier '{}' already declared", name), declaration->source_range().start);
|
||||
m_parser.syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", name), declaration->source_range().start);
|
||||
}
|
||||
|
||||
Parser& m_parser;
|
||||
|
@ -579,7 +579,7 @@ void Parser::parse_module(Program& program)
|
|||
}
|
||||
|
||||
if (!found)
|
||||
syntax_error(String::formatted("'{}' in export is not declared", exported_name), export_statement.source_range().start);
|
||||
syntax_error(DeprecatedString::formatted("'{}' in export is not declared", exported_name), export_statement.source_range().start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -664,9 +664,9 @@ NonnullRefPtr<Statement> Parser::parse_statement(AllowLabelledFunction allow_lab
|
|||
if (lookahead_token.type() == TokenType::Function && !lookahead_token.trivia_contains_line_terminator())
|
||||
syntax_error("Async function declaration not allowed in single-statement context");
|
||||
} else if (match(TokenType::Function) || match(TokenType::Class)) {
|
||||
syntax_error(String::formatted("{} declaration not allowed in single-statement context", m_state.current_token.name()));
|
||||
syntax_error(DeprecatedString::formatted("{} declaration not allowed in single-statement context", m_state.current_token.name()));
|
||||
} else if (match(TokenType::Let) && next_token().type() == TokenType::BracketOpen) {
|
||||
syntax_error(String::formatted("let followed by [ is not allowed in single-statement context"));
|
||||
syntax_error(DeprecatedString::formatted("let followed by [ is not allowed in single-statement context"));
|
||||
}
|
||||
|
||||
auto expr = parse_expression(0);
|
||||
|
@ -853,7 +853,7 @@ RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expe
|
|||
|
||||
auto function_start_offset = rule_start.position().offset;
|
||||
auto function_end_offset = position().offset - m_state.current_token.trivia().length();
|
||||
auto source_text = String { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
|
||||
auto source_text = DeprecatedString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
|
||||
return create_ast_node<FunctionExpression>(
|
||||
{ m_source_code, rule_start.position(), position() }, "", move(source_text),
|
||||
move(body), move(parameters), function_length, function_kind, body->in_strict_mode(),
|
||||
|
@ -909,7 +909,7 @@ RefPtr<LabelledStatement> Parser::try_parse_labelled_statement(AllowLabelledFunc
|
|||
}
|
||||
|
||||
if (m_state.labels_in_scope.contains(identifier))
|
||||
syntax_error(String::formatted("Label '{}' has already been declared", identifier));
|
||||
syntax_error(DeprecatedString::formatted("Label '{}' has already been declared", identifier));
|
||||
|
||||
RefPtr<Statement> labelled_item;
|
||||
|
||||
|
@ -1172,7 +1172,7 @@ NonnullRefPtr<ClassExpression> Parser::parse_class_expression(bool expect_class_
|
|||
|
||||
if (element.class_element_kind() != ClassElement::ElementKind::Method
|
||||
|| element.is_static() != is_static) {
|
||||
syntax_error(String::formatted("Duplicate private field or method named '{}'", name));
|
||||
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1180,14 +1180,14 @@ NonnullRefPtr<ClassExpression> Parser::parse_class_expression(bool expect_class_
|
|||
auto& class_method_element = static_cast<ClassMethod const&>(element);
|
||||
|
||||
if (class_method_element.kind() == ClassMethod::Kind::Method || class_method_element.kind() == method_kind) {
|
||||
syntax_error(String::formatted("Duplicate private field or method named '{}'", name));
|
||||
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
found_private_names.set(name);
|
||||
} else if (found_private_names.set(name) != AK::HashSetResult::InsertedNewEntry) {
|
||||
syntax_error(String::formatted("Duplicate private field or method named '{}'", name));
|
||||
syntax_error(DeprecatedString::formatted("Duplicate private field or method named '{}'", name));
|
||||
}
|
||||
|
||||
property_key = create_ast_node<PrivateIdentifier>({ m_source_code, rule_start.position(), position() }, name);
|
||||
|
@ -1360,12 +1360,12 @@ NonnullRefPtr<ClassExpression> Parser::parse_class_expression(bool expect_class_
|
|||
if (outer_referenced_private_names)
|
||||
outer_referenced_private_names->set(private_name);
|
||||
else // FIXME: Make these error appear in the appropriate places.
|
||||
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", private_name));
|
||||
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", private_name));
|
||||
}
|
||||
|
||||
auto function_start_offset = rule_start.position().offset;
|
||||
auto function_end_offset = position().offset - m_state.current_token.trivia().length();
|
||||
auto source_text = String { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
|
||||
auto source_text = DeprecatedString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
|
||||
|
||||
return create_ast_node<ClassExpression>({ m_source_code, rule_start.position(), position() }, move(class_name), move(source_text), move(constructor), move(super_class), move(elements));
|
||||
}
|
||||
|
@ -1428,7 +1428,7 @@ Parser::PrimaryExpressionParseResult Parser::parse_primary_expression()
|
|||
auto string = m_state.current_token.value();
|
||||
// This could be 'eval' or 'arguments' and thus needs a custom check (`eval[1] = true`)
|
||||
if (m_state.strict_mode && (string == "let" || is_strict_reserved_word(string)))
|
||||
syntax_error(String::formatted("Identifier must not be a reserved word in strict mode ('{}')", string));
|
||||
syntax_error(DeprecatedString::formatted("Identifier must not be a reserved word in strict mode ('{}')", string));
|
||||
return { parse_identifier() };
|
||||
}
|
||||
case TokenType::NumericLiteral:
|
||||
|
@ -1507,7 +1507,7 @@ Parser::PrimaryExpressionParseResult Parser::parse_primary_expression()
|
|||
return { parse_await_expression() };
|
||||
case TokenType::PrivateIdentifier:
|
||||
if (!is_private_identifier_valid())
|
||||
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
if (next_token().type() != TokenType::In)
|
||||
syntax_error("Cannot have a private identifier in expression if not followed by 'in'");
|
||||
return { create_ast_node<PrivateIdentifier>({ m_source_code, rule_start.position(), position() }, consume().value()) };
|
||||
|
@ -1528,7 +1528,7 @@ NonnullRefPtr<RegExpLiteral> Parser::parse_regexp_literal()
|
|||
// Remove leading and trailing slash.
|
||||
pattern = pattern.substring_view(1, pattern.length() - 2);
|
||||
|
||||
auto flags = String::empty();
|
||||
auto flags = DeprecatedString::empty();
|
||||
auto parsed_flags = RegExpObject::default_flags;
|
||||
|
||||
if (match(TokenType::RegexFlags)) {
|
||||
|
@ -1542,18 +1542,18 @@ NonnullRefPtr<RegExpLiteral> Parser::parse_regexp_literal()
|
|||
parsed_flags = parsed_flags_or_error.release_value();
|
||||
}
|
||||
|
||||
String parsed_pattern;
|
||||
DeprecatedString parsed_pattern;
|
||||
auto parsed_pattern_result = parse_regex_pattern(pattern, parsed_flags.has_flag_set(ECMAScriptFlags::Unicode), parsed_flags.has_flag_set(ECMAScriptFlags::UnicodeSets));
|
||||
if (parsed_pattern_result.is_error()) {
|
||||
syntax_error(parsed_pattern_result.release_error().error, rule_start.position());
|
||||
parsed_pattern = String::empty();
|
||||
parsed_pattern = DeprecatedString::empty();
|
||||
} else {
|
||||
parsed_pattern = parsed_pattern_result.release_value();
|
||||
}
|
||||
auto parsed_regex = Regex<ECMA262>::parse_pattern(parsed_pattern, parsed_flags);
|
||||
|
||||
if (parsed_regex.error != regex::Error::NoError)
|
||||
syntax_error(String::formatted("RegExp compile error: {}", Regex<ECMA262>(parsed_regex, parsed_pattern, parsed_flags).error_string()), rule_start.position());
|
||||
syntax_error(DeprecatedString::formatted("RegExp compile error: {}", Regex<ECMA262>(parsed_regex, parsed_pattern, parsed_flags).error_string()), rule_start.position());
|
||||
|
||||
SourceRange range { m_source_code, rule_start.position(), position() };
|
||||
return create_ast_node<RegExpLiteral>(move(range), move(parsed_regex), move(parsed_pattern), move(parsed_flags), pattern.to_string(), move(flags));
|
||||
|
@ -1575,7 +1575,7 @@ NonnullRefPtr<Expression> Parser::parse_unary_prefixed_expression()
|
|||
auto rhs_start = position();
|
||||
auto rhs = parse_expression(precedence, associativity);
|
||||
if (!is_simple_assignment_target(*rhs))
|
||||
syntax_error(String::formatted("Right-hand side of prefix increment operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
|
||||
syntax_error(DeprecatedString::formatted("Right-hand side of prefix increment operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
|
||||
|
||||
if (m_state.strict_mode && is<Identifier>(*rhs)) {
|
||||
auto& identifier = static_cast<Identifier&>(*rhs);
|
||||
|
@ -1590,7 +1590,7 @@ NonnullRefPtr<Expression> Parser::parse_unary_prefixed_expression()
|
|||
auto rhs_start = position();
|
||||
auto rhs = parse_expression(precedence, associativity);
|
||||
if (!is_simple_assignment_target(*rhs))
|
||||
syntax_error(String::formatted("Right-hand side of prefix decrement operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
|
||||
syntax_error(DeprecatedString::formatted("Right-hand side of prefix decrement operator must be identifier or member expression, got {}", rhs->class_name()), rhs_start);
|
||||
|
||||
if (m_state.strict_mode && is<Identifier>(*rhs)) {
|
||||
auto& identifier = static_cast<Identifier&>(*rhs);
|
||||
|
@ -1784,7 +1784,7 @@ NonnullRefPtr<ObjectExpression> Parser::parse_object_expression()
|
|||
if (m_state.strict_mode && is<StringLiteral>(*property_key)) {
|
||||
auto& string_literal = static_cast<StringLiteral const&>(*property_key);
|
||||
if (is_strict_reserved_word(string_literal.value()))
|
||||
syntax_error(String::formatted("'{}' is a reserved keyword", string_literal.value()));
|
||||
syntax_error(DeprecatedString::formatted("'{}' is a reserved keyword", string_literal.value()));
|
||||
}
|
||||
|
||||
properties.append(create_ast_node<ObjectProperty>({ m_source_code, rule_start.position(), position() }, *property_key, *property_value, property_type, false));
|
||||
|
@ -1845,7 +1845,7 @@ NonnullRefPtr<StringLiteral> Parser::parse_string_literal(Token const& token, St
|
|||
auto string = token.string_value(status);
|
||||
// NOTE: Tagged templates should not fail on invalid strings as their raw contents can still be accessed.
|
||||
if (status != Token::StringValueStatus::Ok) {
|
||||
String message;
|
||||
DeprecatedString message;
|
||||
if (status == Token::StringValueStatus::LegacyOctalEscapeSequence) {
|
||||
m_state.string_legacy_octal_escape_sequence_in_scope = true;
|
||||
// It is a Syntax Error if the [Tagged] parameter was not set and Template{Head, Middle, Tail} Contains NotEscapeSequence.
|
||||
|
@ -1855,7 +1855,7 @@ NonnullRefPtr<StringLiteral> Parser::parse_string_literal(Token const& token, St
|
|||
message = "Octal escape sequence in string literal not allowed in strict mode";
|
||||
} else if (status == Token::StringValueStatus::MalformedHexEscape || status == Token::StringValueStatus::MalformedUnicodeEscape) {
|
||||
auto type = status == Token::StringValueStatus::MalformedUnicodeEscape ? "unicode" : "hexadecimal";
|
||||
message = String::formatted("Malformed {} escape sequence", type);
|
||||
message = DeprecatedString::formatted("Malformed {} escape sequence", type);
|
||||
} else if (status == Token::StringValueStatus::UnicodeEscapeOverflow) {
|
||||
message = "Unicode code_point must not be greater than 0x10ffff in escape sequence";
|
||||
} else {
|
||||
|
@ -2129,9 +2129,9 @@ Parser::ExpressionResult Parser::parse_secondary_expression(NonnullRefPtr<Expres
|
|||
consume();
|
||||
if (match(TokenType::PrivateIdentifier)) {
|
||||
if (!is_private_identifier_valid())
|
||||
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
else if (is<SuperExpression>(*lhs))
|
||||
syntax_error(String::formatted("Cannot access private field or method '{}' on super", m_state.current_token.value()));
|
||||
syntax_error(DeprecatedString::formatted("Cannot access private field or method '{}' on super", m_state.current_token.value()));
|
||||
|
||||
return create_ast_node<MemberExpression>({ m_source_code, rule_start.position(), position() }, move(lhs), create_ast_node<PrivateIdentifier>({ m_source_code, rule_start.position(), position() }, consume().value()));
|
||||
} else if (!match_identifier_name()) {
|
||||
|
@ -2147,7 +2147,7 @@ Parser::ExpressionResult Parser::parse_secondary_expression(NonnullRefPtr<Expres
|
|||
}
|
||||
case TokenType::PlusPlus:
|
||||
if (!is_simple_assignment_target(*lhs))
|
||||
syntax_error(String::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
|
||||
syntax_error(DeprecatedString::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
|
||||
|
||||
if (m_state.strict_mode && is<Identifier>(*lhs)) {
|
||||
auto& identifier = static_cast<Identifier&>(*lhs);
|
||||
|
@ -2159,7 +2159,7 @@ Parser::ExpressionResult Parser::parse_secondary_expression(NonnullRefPtr<Expres
|
|||
return create_ast_node<UpdateExpression>({ m_source_code, rule_start.position(), position() }, UpdateOp::Increment, move(lhs));
|
||||
case TokenType::MinusMinus:
|
||||
if (!is_simple_assignment_target(*lhs))
|
||||
syntax_error(String::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
|
||||
syntax_error(DeprecatedString::formatted("Left-hand side of postfix increment operator must be identifier or member expression, got {}", lhs->class_name()));
|
||||
|
||||
if (m_state.strict_mode && is<Identifier>(*lhs)) {
|
||||
auto& identifier = static_cast<Identifier&>(*lhs);
|
||||
|
@ -2502,7 +2502,7 @@ NonnullRefPtr<FunctionBody> Parser::parse_function_body(Vector<FunctionParameter
|
|||
|
||||
for (auto& previous_name : parameter_names) {
|
||||
if (previous_name == parameter_name) {
|
||||
syntax_error(String::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name));
|
||||
syntax_error(DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2518,7 +2518,7 @@ NonnullRefPtr<FunctionBody> Parser::parse_function_body(Vector<FunctionParameter
|
|||
|
||||
for (auto& previous_name : parameter_names) {
|
||||
if (previous_name == bound_name) {
|
||||
syntax_error(String::formatted("Duplicate parameter '{}' not allowed in strict mode", bound_name));
|
||||
syntax_error(DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", bound_name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2594,7 +2594,7 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u16 parse_options, O
|
|||
check_identifier_name_for_assignment_validity(name);
|
||||
|
||||
if (function_kind == FunctionKind::AsyncGenerator && (name == "await"sv || name == "yield"sv))
|
||||
syntax_error(String::formatted("async generator function is not allowed to be called '{}'", name));
|
||||
syntax_error(DeprecatedString::formatted("async generator function is not allowed to be called '{}'", name));
|
||||
|
||||
if (m_state.in_class_static_init_block && name == "await"sv)
|
||||
syntax_error("'await' is a reserved word");
|
||||
|
@ -2630,7 +2630,7 @@ NonnullRefPtr<FunctionNodeType> Parser::parse_function_node(u16 parse_options, O
|
|||
|
||||
auto function_start_offset = rule_start.position().offset;
|
||||
auto function_end_offset = position().offset - m_state.current_token.trivia().length();
|
||||
auto source_text = String { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
|
||||
auto source_text = DeprecatedString { m_state.lexer.source().substring_view(function_start_offset, function_end_offset - function_start_offset) };
|
||||
return create_ast_node<FunctionNodeType>(
|
||||
{ m_source_code, rule_start.position(), position() },
|
||||
name, move(source_text), move(body), move(parameters), function_length,
|
||||
|
@ -2673,15 +2673,15 @@ Vector<FunctionParameter> Parser::parse_formal_parameters(int& function_length,
|
|||
if (!has_same_name)
|
||||
continue;
|
||||
|
||||
String message;
|
||||
DeprecatedString message;
|
||||
if (parse_options & FunctionNodeParseOptions::IsArrowFunction)
|
||||
message = String::formatted("Duplicate parameter '{}' not allowed in arrow function", parameter_name);
|
||||
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in arrow function", parameter_name);
|
||||
else if (m_state.strict_mode)
|
||||
message = String::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name);
|
||||
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in strict mode", parameter_name);
|
||||
else if (has_default_parameter || match(TokenType::Equals))
|
||||
message = String::formatted("Duplicate parameter '{}' not allowed in function with default parameter", parameter_name);
|
||||
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in function with default parameter", parameter_name);
|
||||
else if (has_rest_parameter)
|
||||
message = String::formatted("Duplicate parameter '{}' not allowed in function with rest parameter", parameter_name);
|
||||
message = DeprecatedString::formatted("Duplicate parameter '{}' not allowed in function with rest parameter", parameter_name);
|
||||
if (!message.is_empty())
|
||||
syntax_error(message, Position { token.line_number(), token.line_column() });
|
||||
break;
|
||||
|
@ -3066,7 +3066,7 @@ NonnullRefPtr<BreakStatement> Parser::parse_break_statement()
|
|||
|
||||
auto label = m_state.labels_in_scope.find(target_label);
|
||||
if (label == m_state.labels_in_scope.end())
|
||||
syntax_error(String::formatted("Label '{}' not found", target_label));
|
||||
syntax_error(DeprecatedString::formatted("Label '{}' not found", target_label));
|
||||
}
|
||||
consume_or_insert_semicolon();
|
||||
}
|
||||
|
@ -3095,7 +3095,7 @@ NonnullRefPtr<ContinueStatement> Parser::parse_continue_statement()
|
|||
|
||||
auto label = m_state.labels_in_scope.find(target_label);
|
||||
if (label == m_state.labels_in_scope.end())
|
||||
syntax_error(String::formatted("Label '{}' not found or invalid", target_label));
|
||||
syntax_error(DeprecatedString::formatted("Label '{}' not found or invalid", target_label));
|
||||
else
|
||||
label->value = label_position;
|
||||
}
|
||||
|
@ -3131,7 +3131,7 @@ NonnullRefPtr<OptionalChain> Parser::parse_optional_chain(NonnullRefPtr<Expressi
|
|||
break;
|
||||
case TokenType::PrivateIdentifier: {
|
||||
if (!is_private_identifier_valid())
|
||||
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
|
||||
auto start = position();
|
||||
auto private_identifier = consume();
|
||||
|
@ -3167,7 +3167,7 @@ NonnullRefPtr<OptionalChain> Parser::parse_optional_chain(NonnullRefPtr<Expressi
|
|||
consume();
|
||||
if (match(TokenType::PrivateIdentifier)) {
|
||||
if (!is_private_identifier_valid())
|
||||
syntax_error(String::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
syntax_error(DeprecatedString::formatted("Reference to undeclared private field or method '{}'", m_state.current_token.value()));
|
||||
|
||||
auto start = position();
|
||||
auto private_identifier = consume();
|
||||
|
@ -3382,7 +3382,7 @@ NonnullRefPtr<CatchClause> Parser::parse_catch_clause()
|
|||
|
||||
body->for_each_lexically_declared_name([&](auto const& name) {
|
||||
if (bound_names.contains(name))
|
||||
syntax_error(String::formatted("Identifier '{}' already declared as catch parameter", name));
|
||||
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared as catch parameter", name));
|
||||
});
|
||||
|
||||
if (pattern_parameter) {
|
||||
|
@ -3494,7 +3494,7 @@ NonnullRefPtr<Statement> Parser::parse_for_statement()
|
|||
HashTable<FlyString> bound_names;
|
||||
declaration->for_each_bound_name([&](auto const& name) {
|
||||
if (bound_names.set(name) != AK::HashSetResult::InsertedNewEntry)
|
||||
syntax_error(String::formatted("Identifier '{}' already declared in for loop initializer", name), declaration->source_range().start);
|
||||
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared in for loop initializer", name), declaration->source_range().start);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3577,7 +3577,7 @@ NonnullRefPtr<Statement> Parser::parse_for_in_of_statement(NonnullRefPtr<ASTNode
|
|||
}
|
||||
}
|
||||
if (!valid)
|
||||
syntax_error(String::formatted("Invalid left-hand side in for-loop ('{}')", lhs->class_name()));
|
||||
syntax_error(DeprecatedString::formatted("Invalid left-hand side in for-loop ('{}')", lhs->class_name()));
|
||||
}
|
||||
auto in_or_of = consume();
|
||||
auto is_in = in_or_of.type() == TokenType::In;
|
||||
|
@ -3928,7 +3928,7 @@ Token Parser::consume_identifier_reference()
|
|||
if (match(TokenType::EscapedKeyword)) {
|
||||
auto name = m_state.current_token.value();
|
||||
if (m_state.strict_mode && (name == "let"sv || name == "yield"sv))
|
||||
syntax_error(String::formatted("'{}' is not allowed as an identifier in strict mode", name));
|
||||
syntax_error(DeprecatedString::formatted("'{}' is not allowed as an identifier in strict mode", name));
|
||||
if (m_program_type == Program::Type::Module && name == "await"sv)
|
||||
syntax_error("'await' is not allowed as an identifier in module");
|
||||
|
||||
|
@ -3969,7 +3969,7 @@ Token Parser::consume(TokenType expected_type)
|
|||
auto token = consume();
|
||||
if (expected_type == TokenType::Identifier) {
|
||||
if (m_state.strict_mode && is_strict_reserved_word(token.value()))
|
||||
syntax_error(String::formatted("Identifier must not be a reserved word in strict mode ('{}')", token.value()));
|
||||
syntax_error(DeprecatedString::formatted("Identifier must not be a reserved word in strict mode ('{}')", token.value()));
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
@ -3992,7 +3992,7 @@ void Parser::expected(char const* what)
|
|||
{
|
||||
auto message = m_state.current_token.message();
|
||||
if (message.is_empty())
|
||||
message = String::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what);
|
||||
message = DeprecatedString::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what);
|
||||
syntax_error(message);
|
||||
}
|
||||
|
||||
|
@ -4019,7 +4019,7 @@ void Parser::set_try_parse_arrow_function_expression_failed_at_position(Position
|
|||
m_token_memoizations.set(position, { failed });
|
||||
}
|
||||
|
||||
void Parser::syntax_error(String const& message, Optional<Position> position)
|
||||
void Parser::syntax_error(DeprecatedString const& message, Optional<Position> position)
|
||||
{
|
||||
if (!position.has_value())
|
||||
position = this->position();
|
||||
|
@ -4051,7 +4051,7 @@ void Parser::check_identifier_name_for_assignment_validity(FlyString const& name
|
|||
if (name.is_one_of("arguments"sv, "eval"sv))
|
||||
syntax_error("Binding pattern target may not be called 'arguments' or 'eval' in strict mode");
|
||||
else if (is_strict_reserved_word(name))
|
||||
syntax_error(String::formatted("Binding pattern target may not be called '{}' in strict mode", name));
|
||||
syntax_error(DeprecatedString::formatted("Binding pattern target may not be called '{}' in strict mode", name));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4102,7 +4102,7 @@ ModuleRequest Parser::parse_module_request()
|
|||
consume(TokenType::CurlyOpen);
|
||||
|
||||
while (!done() && !match(TokenType::CurlyClose)) {
|
||||
String key;
|
||||
DeprecatedString key;
|
||||
if (match(TokenType::StringLiteral)) {
|
||||
key = parse_string_literal(m_state.current_token)->value().to_string();
|
||||
consume();
|
||||
|
@ -4118,7 +4118,7 @@ ModuleRequest Parser::parse_module_request()
|
|||
if (match(TokenType::StringLiteral)) {
|
||||
for (auto& entries : request.assertions) {
|
||||
if (entries.key == key)
|
||||
syntax_error(String::formatted("Duplicate assertion clauses with name: {}", key));
|
||||
syntax_error(DeprecatedString::formatted("Duplicate assertion clauses with name: {}", key));
|
||||
}
|
||||
request.add_assertion(move(key), parse_string_literal(m_state.current_token)->value().to_string());
|
||||
}
|
||||
|
@ -4202,7 +4202,7 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
|
|||
consume(TokenType::Asterisk);
|
||||
|
||||
if (!match_as())
|
||||
syntax_error(String::formatted("Unexpected token: {}", m_state.current_token.name()));
|
||||
syntax_error(DeprecatedString::formatted("Unexpected token: {}", m_state.current_token.name()));
|
||||
|
||||
consume(TokenType::Identifier);
|
||||
|
||||
|
@ -4211,7 +4211,7 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
|
|||
auto namespace_name = consume().value();
|
||||
entries_with_location.append({ ImportEntry({}, namespace_name, true), namespace_position });
|
||||
} else {
|
||||
syntax_error(String::formatted("Unexpected token: {}", m_state.current_token.name()));
|
||||
syntax_error(DeprecatedString::formatted("Unexpected token: {}", m_state.current_token.name()));
|
||||
}
|
||||
|
||||
} else if (match(TokenType::CurlyOpen)) {
|
||||
|
@ -4235,7 +4235,7 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
|
|||
|
||||
entries_with_location.append({ { name, alias }, alias_position });
|
||||
} else if (require_as) {
|
||||
syntax_error(String::formatted("Unexpected reserved word '{}'", name));
|
||||
syntax_error(DeprecatedString::formatted("Unexpected reserved word '{}'", name));
|
||||
} else {
|
||||
check_identifier_name_for_assignment_validity(name);
|
||||
|
||||
|
@ -4273,7 +4273,7 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
|
|||
|
||||
auto from_statement = consume(TokenType::Identifier).original_value();
|
||||
if (from_statement != "from"sv)
|
||||
syntax_error(String::formatted("Expected 'from' got {}", from_statement));
|
||||
syntax_error(DeprecatedString::formatted("Expected 'from' got {}", from_statement));
|
||||
|
||||
auto module_request = parse_module_request();
|
||||
|
||||
|
@ -4283,12 +4283,12 @@ NonnullRefPtr<ImportStatement> Parser::parse_import_statement(Program& program)
|
|||
for (auto& entry : entries_with_location) {
|
||||
for (auto& import_statement : program.imports()) {
|
||||
if (import_statement.has_bound_name(entry.entry.local_name))
|
||||
syntax_error(String::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
|
||||
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
|
||||
}
|
||||
|
||||
for (auto& new_entry : entries) {
|
||||
if (new_entry.local_name == entry.entry.local_name)
|
||||
syntax_error(String::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
|
||||
syntax_error(DeprecatedString::formatted("Identifier '{}' already declared", entry.entry.local_name), entry.position);
|
||||
}
|
||||
|
||||
entries.append(move(entry.entry));
|
||||
|
@ -4582,12 +4582,12 @@ NonnullRefPtr<ExportStatement> Parser::parse_export_statement(Program& program)
|
|||
for (auto& entry : entries_with_location) {
|
||||
for (auto& export_statement : program.exports()) {
|
||||
if (export_statement.has_export(entry.entry.export_name))
|
||||
syntax_error(String::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
|
||||
syntax_error(DeprecatedString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
|
||||
}
|
||||
|
||||
for (auto& new_entry : entries) {
|
||||
if (new_entry.kind != ExportEntry::Kind::EmptyNamedExport && new_entry.export_name == entry.entry.export_name)
|
||||
syntax_error(String::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
|
||||
syntax_error(DeprecatedString::formatted("Duplicate export with name: '{}'", entry.entry.export_name), entry.position);
|
||||
}
|
||||
|
||||
entries.append(move(entry.entry));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue