src: replace std::array with static arrays in contextify

PR-URL: https://github.com/nodejs/node/pull/58580
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Mert Can Altin 2025-06-10 13:59:14 +03:00 committed by GitHub
parent d0b6194add
commit 238af6a8b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1622,7 +1622,7 @@ MaybeLocal<Object> ContextifyFunction::CompileFunctionAndCacheResult(
// While top-level `await` is not permitted in CommonJS, it returns the same // While top-level `await` is not permitted in CommonJS, it returns the same
// error message as when `await` is used in a sync function, so we don't use it // error message as when `await` is used in a sync function, so we don't use it
// as a disambiguation. // as a disambiguation.
static std::vector<std::string_view> esm_syntax_error_messages = { static const auto esm_syntax_error_messages = std::array<std::string_view, 3>{
"Cannot use import statement outside a module", // `import` statements "Cannot use import statement outside a module", // `import` statements
"Unexpected token 'export'", // `export` statements "Unexpected token 'export'", // `export` statements
"Cannot use 'import.meta' outside a module"}; // `import.meta` references "Cannot use 'import.meta' outside a module"}; // `import.meta` references
@ -1637,7 +1637,8 @@ static std::vector<std::string_view> esm_syntax_error_messages = {
// - Top-level `await`: if the user writes `await` at the top level of a // - Top-level `await`: if the user writes `await` at the top level of a
// CommonJS module, it will throw a syntax error; but the same code is valid // CommonJS module, it will throw a syntax error; but the same code is valid
// in ESM. // in ESM.
static std::vector<std::string_view> throws_only_in_cjs_error_messages = { static const auto throws_only_in_cjs_error_messages =
std::array<std::string_view, 6>{
"Identifier 'module' has already been declared", "Identifier 'module' has already been declared",
"Identifier 'exports' has already been declared", "Identifier 'exports' has already been declared",
"Identifier 'require' has already been declared", "Identifier 'require' has already been declared",