1 // Copyright 2018 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_COMMON_MESSAGE_TEMPLATE_H_
6 #define V8_COMMON_MESSAGE_TEMPLATE_H_
7
8 #include "src/base/logging.h"
9
10 namespace v8 {
11 namespace internal {
12
13 #define MESSAGE_TEMPLATES(T) \
14 /* Error */ \
15 T(None, "") \
16 T(CyclicProto, "Cyclic __proto__ value") \
17 T(Debugger, "Debugger: %") \
18 T(DebuggerLoading, "Error loading debugger") \
19 T(DefaultOptionsMissing, "Internal % error. Default options are missing.") \
20 T(DeletePrivateField, "Private fields can not be deleted") \
21 T(UncaughtException, "Uncaught %") \
22 T(Unsupported, "Not supported") \
23 T(WrongServiceType, "Internal error, wrong service type: %") \
24 T(WrongValueType, "Internal error. Wrong value type.") \
25 T(IcuError, "Internal error. Icu error.") \
26 /* TypeError */ \
27 T(ApplyNonFunction, \
28 "Function.prototype.apply was called on %, which is a % and not a " \
29 "function") \
30 T(ArgumentsDisallowedInInitializer, \
31 "'arguments' is not allowed in class field initializer") \
32 T(ArrayBufferTooShort, \
33 "Derived ArrayBuffer constructor created a buffer which was too small") \
34 T(ArrayBufferSpeciesThis, \
35 "ArrayBuffer subclass returned this from species constructor") \
36 T(AwaitNotInAsyncContext, \
37 "await is only valid in async functions and the top level bodies of " \
38 "modules") \
39 T(AwaitNotInAsyncFunction, "await is only valid in async function") \
40 T(AtomicsWaitNotAllowed, "Atomics.wait cannot be called in this context") \
41 T(BadSortComparisonFunction, \
42 "The comparison function must be either a function or undefined") \
43 T(BigIntFromNumber, \
44 "The number % cannot be converted to a BigInt because it is not an " \
45 "integer") \
46 T(BigIntFromObject, "Cannot convert % to a BigInt") \
47 T(BigIntMixedTypes, \
48 "Cannot mix BigInt and other types, use explicit conversions") \
49 T(BigIntSerializeJSON, "Do not know how to serialize a BigInt") \
50 T(BigIntShr, "BigInts have no unsigned right shift, use >> instead") \
51 T(BigIntToNumber, "Cannot convert a BigInt value to a number") \
52 T(CalledNonCallable, "% is not a function") \
53 T(CalledOnNonObject, "% called on non-object") \
54 T(CalledOnNullOrUndefined, "% called on null or undefined") \
55 T(CallSiteExpectsFunction, \
56 "CallSite expects wasm object as first or function as second argument, " \
57 "got <%, %>") \
58 T(CallSiteMethod, "CallSite method % expects CallSite as receiver") \
59 T(CannotConvertToPrimitive, "Cannot convert object to primitive value") \
60 T(CannotPreventExt, "Cannot prevent extensions") \
61 T(CannotFreeze, "Cannot freeze") \
62 T(CannotFreezeArrayBufferView, \
63 "Cannot freeze array buffer views with elements") \
64 T(CannotSeal, "Cannot seal") \
65 T(CircularStructure, "Converting circular structure to JSON%") \
66 T(ConstructAbstractClass, "Abstract class % not directly constructable") \
67 T(ConstAssign, "Assignment to constant variable.") \
68 T(ConstructorClassField, "Classes may not have a field named 'constructor'") \
69 T(ConstructorNonCallable, \
70 "Class constructor % cannot be invoked without 'new'") \
71 T(AnonymousConstructorNonCallable, \
72 "Class constructors cannot be invoked without 'new'") \
73 T(ConstructorNotFunction, "Constructor % requires 'new'") \
74 T(ConstructorNotReceiver, "The .constructor property is not an object") \
75 T(CurrencyCode, "Currency code is required with currency style.") \
76 T(CyclicModuleDependency, "Detected cycle while resolving name '%' in '%'") \
77 T(DataViewNotArrayBuffer, \
78 "First argument to DataView constructor must be an ArrayBuffer") \
79 T(DateType, "this is not a Date object.") \
80 T(DebuggerFrame, "Debugger: Invalid frame index.") \
81 T(DebuggerType, "Debugger: Parameters have wrong types.") \
82 T(DeclarationMissingInitializer, "Missing initializer in % declaration") \
83 T(DefineDisallowed, "Cannot define property %, object is not extensible") \
84 T(DetachedOperation, "Cannot perform % on a detached ArrayBuffer") \
85 T(DuplicateTemplateProperty, "Object template has duplicate property '%'") \
86 T(ExtendsValueNotConstructor, \
87 "Class extends value % is not a constructor or null") \
88 T(FirstArgumentNotRegExp, \
89 "First argument to % must not be a regular expression") \
90 T(FunctionBind, "Bind must be called on a function") \
91 T(GeneratorRunning, "Generator is already running") \
92 T(IllegalInvocation, "Illegal invocation") \
93 T(ImmutablePrototypeSet, \
94 "Immutable prototype object '%' cannot have their prototype set") \
95 T(ImportAssertionDuplicateKey, "Import assertion has duplicate key '%'") \
96 T(ImportCallNotNewExpression, "Cannot use new with import") \
97 T(ImportOutsideModule, "Cannot use import statement outside a module") \
98 T(ImportMetaOutsideModule, "Cannot use 'import.meta' outside a module") \
99 T(ImportMissingSpecifier, "import() requires a specifier") \
100 T(IncompatibleMethodReceiver, "Method % called on incompatible receiver %") \
101 T(InstanceofNonobjectProto, \
102 "Function has non-object prototype '%' in instanceof check") \
103 T(InvalidArgument, "invalid_argument") \
104 T(InvalidInOperatorUse, "Cannot use 'in' operator to search for '%' in %") \
105 T(InvalidRegExpExecResult, \
106 "RegExp exec method returned something other than an Object or null") \
107 T(InvalidUnit, "Invalid unit argument for %() '%'") \
108 T(IterableYieldedNonString, "Iterable yielded % which is not a string") \
109 T(IteratorResultNotAnObject, "Iterator result % is not an object") \
110 T(IteratorSymbolNonCallable, "Found non-callable @@iterator") \
111 T(IteratorValueNotAnObject, "Iterator value % is not an entry object") \
112 T(LanguageID, "Language ID should be string or object.") \
113 T(LocaleNotEmpty, \
114 "First argument to Intl.Locale constructor can't be empty or missing") \
115 T(LocaleBadParameters, "Incorrect locale information provided") \
116 T(ListFormatBadParameters, "Incorrect ListFormat information provided") \
117 T(MapperFunctionNonCallable, "flatMap mapper function is not callable") \
118 T(MethodCalledOnWrongObject, \
119 "Method % called on a non-object or on a wrong type of object.") \
120 T(MethodInvokedOnWrongType, "Method invoked on an object that is not %.") \
121 T(NoAccess, "no access") \
122 T(NonCallableInInstanceOfCheck, \
123 "Right-hand side of 'instanceof' is not callable") \
124 T(NonCoercible, "Cannot destructure '%' as it is %.") \
125 T(NonCoercibleWithProperty, \
126 "Cannot destructure property '%' of '%' as it is %.") \
127 T(NonExtensibleProto, "% is not extensible") \
128 T(NonObjectInInstanceOfCheck, \
129 "Right-hand side of 'instanceof' is not an object") \
130 T(NonObjectPropertyLoad, "Cannot read property '%' of %") \
131 T(NonObjectPropertyStore, "Cannot set property '%' of %") \
132 T(NoSetterInCallback, "Cannot set property % of % which has only a getter") \
133 T(NotAnIterator, "% is not an iterator") \
134 T(NotAPromise, "% is not a promise") \
135 T(NotConstructor, "% is not a constructor") \
136 T(NotDateObject, "this is not a Date object.") \
137 T(NotGeneric, "% requires that 'this' be a %") \
138 T(NotCallableOrIterable, \
139 "% is not a function or its return value is not iterable") \
140 T(NotCallableOrAsyncIterable, \
141 "% is not a function or its return value is not async iterable") \
142 T(NotFiniteNumber, "Value need to be finite number for %()") \
143 T(NotIterable, "% is not iterable") \
144 T(NotIterableNoSymbolLoad, "% is not iterable (cannot read property %)") \
145 T(NotAsyncIterable, "% is not async iterable") \
146 T(NotPropertyName, "% is not a valid property name") \
147 T(NotTypedArray, "this is not a typed array.") \
148 T(NotSuperConstructor, "Super constructor % of % is not a constructor") \
149 T(NotSuperConstructorAnonymousClass, \
150 "Super constructor % of anonymous class is not a constructor") \
151 T(NotIntegerTypedArray, "% is not an integer typed array.") \
152 T(NotInt32OrBigInt64TypedArray, \
153 "% is not an int32 or BigInt64 typed array.") \
154 T(NotSharedTypedArray, "% is not a shared typed array.") \
155 T(ObjectGetterExpectingFunction, \
156 "Object.prototype.__defineGetter__: Expecting function") \
157 T(ObjectGetterCallable, "Getter must be a function: %") \
158 T(ObjectNotExtensible, "Cannot add property %, object is not extensible") \
159 T(ObjectSetterExpectingFunction, \
160 "Object.prototype.__defineSetter__: Expecting function") \
161 T(ObjectSetterCallable, "Setter must be a function: %") \
162 T(OrdinaryFunctionCalledAsConstructor, \
163 "Function object that's not a constructor was created with new") \
164 T(PromiseCyclic, "Chaining cycle detected for promise %") \
165 T(PromiseExecutorAlreadyInvoked, \
166 "Promise executor has already been invoked with non-undefined arguments") \
167 T(PromiseNonCallable, "Promise resolve or reject function is not callable") \
168 T(PropertyDescObject, "Property description must be an object: %") \
169 T(PropertyNotFunction, \
170 "'%' returned for property '%' of object '%' is not a function") \
171 T(ProtoObjectOrNull, "Object prototype may only be an Object or null: %") \
172 T(PrototypeParentNotAnObject, \
173 "Class extends value does not have valid prototype property %") \
174 T(ProxyConstructNonObject, \
175 "'construct' on proxy: trap returned non-object ('%')") \
176 T(ProxyDefinePropertyNonConfigurable, \
177 "'defineProperty' on proxy: trap returned truish for defining " \
178 "non-configurable property '%' which is either non-existent or " \
179 "configurable in the proxy target") \
180 T(ProxyDefinePropertyNonConfigurableWritable, \
181 "'defineProperty' on proxy: trap returned truish for defining " \
182 "non-configurable property '%' which cannot be non-writable, unless " \
183 "there exists a corresponding non-configurable, non-writable own " \
184 "property of the target object.") \
185 T(ProxyDefinePropertyNonExtensible, \
186 "'defineProperty' on proxy: trap returned truish for adding property '%' " \
187 " to the non-extensible proxy target") \
188 T(ProxyDefinePropertyIncompatible, \
189 "'defineProperty' on proxy: trap returned truish for adding property '%' " \
190 " that is incompatible with the existing property in the proxy target") \
191 T(ProxyDeletePropertyNonConfigurable, \
192 "'deleteProperty' on proxy: trap returned truish for property '%' which " \
193 "is non-configurable in the proxy target") \
194 T(ProxyDeletePropertyNonExtensible, \
195 "'deleteProperty' on proxy: trap returned truish for property '%' but " \
196 "the proxy target is non-extensible") \
197 T(ProxyGetNonConfigurableData, \
198 "'get' on proxy: property '%' is a read-only and " \
199 "non-configurable data property on the proxy target but the proxy " \
200 "did not return its actual value (expected '%' but got '%')") \
201 T(ProxyGetNonConfigurableAccessor, \
202 "'get' on proxy: property '%' is a non-configurable accessor " \
203 "property on the proxy target and does not have a getter function, but " \
204 "the trap did not return 'undefined' (got '%')") \
205 T(ProxyGetOwnPropertyDescriptorIncompatible, \
206 "'getOwnPropertyDescriptor' on proxy: trap returned descriptor for " \
207 "property '%' that is incompatible with the existing property in the " \
208 "proxy target") \
209 T(ProxyGetOwnPropertyDescriptorInvalid, \
210 "'getOwnPropertyDescriptor' on proxy: trap returned neither object nor " \
211 "undefined for property '%'") \
212 T(ProxyGetOwnPropertyDescriptorNonConfigurable, \
213 "'getOwnPropertyDescriptor' on proxy: trap reported non-configurability " \
214 "for property '%' which is either non-existent or configurable in the " \
215 "proxy target") \
216 T(ProxyGetOwnPropertyDescriptorNonConfigurableWritable, \
217 "'getOwnPropertyDescriptor' on proxy: trap reported non-configurable " \
218 "and writable for property '%' which is non-configurable, non-writable " \
219 "in the proxy target") \
220 T(ProxyGetOwnPropertyDescriptorNonExtensible, \
221 "'getOwnPropertyDescriptor' on proxy: trap returned undefined for " \
222 "property '%' which exists in the non-extensible proxy target") \
223 T(ProxyGetOwnPropertyDescriptorUndefined, \
224 "'getOwnPropertyDescriptor' on proxy: trap returned undefined for " \
225 "property '%' which is non-configurable in the proxy target") \
226 T(ProxyGetPrototypeOfInvalid, \
227 "'getPrototypeOf' on proxy: trap returned neither object nor null") \
228 T(ProxyGetPrototypeOfNonExtensible, \
229 "'getPrototypeOf' on proxy: proxy target is non-extensible but the " \
230 "trap did not return its actual prototype") \
231 T(ProxyHasNonConfigurable, \
232 "'has' on proxy: trap returned falsish for property '%' which exists in " \
233 "the proxy target as non-configurable") \
234 T(ProxyHasNonExtensible, \
235 "'has' on proxy: trap returned falsish for property '%' but the proxy " \
236 "target is not extensible") \
237 T(ProxyIsExtensibleInconsistent, \
238 "'isExtensible' on proxy: trap result does not reflect extensibility of " \
239 "proxy target (which is '%')") \
240 T(ProxyNonObject, \
241 "Cannot create proxy with a non-object as target or handler") \
242 T(ProxyOwnKeysMissing, \
243 "'ownKeys' on proxy: trap result did not include '%'") \
244 T(ProxyOwnKeysNonExtensible, \
245 "'ownKeys' on proxy: trap returned extra keys but proxy target is " \
246 "non-extensible") \
247 T(ProxyOwnKeysDuplicateEntries, \
248 "'ownKeys' on proxy: trap returned duplicate entries") \
249 T(ProxyPreventExtensionsExtensible, \
250 "'preventExtensions' on proxy: trap returned truish but the proxy target " \
251 "is extensible") \
252 T(ProxyPrivate, "Cannot pass private property name to proxy trap") \
253 T(ProxyRevoked, "Cannot perform '%' on a proxy that has been revoked") \
254 T(ProxySetFrozenData, \
255 "'set' on proxy: trap returned truish for property '%' which exists in " \
256 "the proxy target as a non-configurable and non-writable data property " \
257 "with a different value") \
258 T(ProxySetFrozenAccessor, \
259 "'set' on proxy: trap returned truish for property '%' which exists in " \
260 "the proxy target as a non-configurable and non-writable accessor " \
261 "property without a setter") \
262 T(ProxySetPrototypeOfNonExtensible, \
263 "'setPrototypeOf' on proxy: trap returned truish for setting a new " \
264 "prototype on the non-extensible proxy target") \
265 T(ProxyTrapReturnedFalsish, "'%' on proxy: trap returned falsish") \
266 T(ProxyTrapReturnedFalsishFor, \
267 "'%' on proxy: trap returned falsish for property '%'") \
268 T(RedefineDisallowed, "Cannot redefine property: %") \
269 T(RedefineExternalArray, \
270 "Cannot redefine a property of an object with external array elements") \
271 T(ReduceNoInitial, "Reduce of empty array with no initial value") \
272 T(RegExpFlags, \
273 "Cannot supply flags when constructing one RegExp from another") \
274 T(RegExpNonObject, "% getter called on non-object %") \
275 T(RegExpNonRegExp, "% getter called on non-RegExp object") \
276 T(RegExpGlobalInvokedOnNonGlobal, \
277 "% called with a non-global RegExp argument") \
278 T(RelativeDateTimeFormatterBadParameters, \
279 "Incorrect RelativeDateTimeFormatter provided") \
280 T(ResolverNotAFunction, "Promise resolver % is not a function") \
281 T(ReturnMethodNotCallable, "The iterator's 'return' method is not callable") \
282 T(SharedArrayBufferTooShort, \
283 "Derived SharedArrayBuffer constructor created a buffer which was too " \
284 "small") \
285 T(SharedArrayBufferSpeciesThis, \
286 "SharedArrayBuffer subclass returned this from species constructor") \
287 T(StaticPrototype, \
288 "Classes may not have a static property named 'prototype'") \
289 T(StrictDeleteProperty, "Cannot delete property '%' of %") \
290 T(StrictPoisonPill, \
291 "'caller', 'callee', and 'arguments' properties may not be accessed on " \
292 "strict mode functions or the arguments objects for calls to them") \
293 T(StrictReadOnlyProperty, \
294 "Cannot assign to read only property '%' of % '%'") \
295 T(StrictCannotCreateProperty, "Cannot create property '%' on % '%'") \
296 T(StringMatchAllNullOrUndefinedFlags, \
297 "The .flags property of the argument to String.prototype.matchAll cannot " \
298 "be null or undefined") \
299 T(SymbolIteratorInvalid, \
300 "Result of the Symbol.iterator method is not an object") \
301 T(SymbolAsyncIteratorInvalid, \
302 "Result of the Symbol.asyncIterator method is not an object") \
303 T(SymbolKeyFor, "% is not a symbol") \
304 T(SymbolToNumber, "Cannot convert a Symbol value to a number") \
305 T(SymbolToString, "Cannot convert a Symbol value to a string") \
306 T(ThrowMethodMissing, "The iterator does not provide a 'throw' method.") \
307 T(UndefinedOrNullToObject, "Cannot convert undefined or null to object") \
308 T(ValueAndAccessor, \
309 "Invalid property descriptor. Cannot both specify accessors and a value " \
310 "or writable attribute, %") \
311 T(VarRedeclaration, "Identifier '%' has already been declared") \
312 T(WrongArgs, "%: Arguments list has wrong type") \
313 /* ReferenceError */ \
314 T(NotDefined, "% is not defined") \
315 T(SuperAlreadyCalled, "Super constructor may only be called once") \
316 T(AccessedUninitializedVariable, "Cannot access '%' before initialization") \
317 T(UnsupportedSuper, "Unsupported reference to 'super'") \
318 /* RangeError */ \
319 T(BigIntDivZero, "Division by zero") \
320 T(BigIntNegativeExponent, "Exponent must be positive") \
321 T(BigIntTooBig, "Maximum BigInt size exceeded") \
322 T(CantSetOptionXWhenYIsUsed, "Can't set option % when % is used") \
323 T(DateRange, "Provided date is not in valid range.") \
324 T(ExpectedLocation, \
325 "Expected letters optionally connected with underscores or hyphens for " \
326 "a location, got %") \
327 T(InvalidArrayBufferLength, "Invalid array buffer length") \
328 T(ArrayBufferAllocationFailed, "Array buffer allocation failed") \
329 T(Invalid, "Invalid % : %") \
330 T(InvalidArrayLength, "Invalid array length") \
331 T(InvalidAtomicAccessIndex, "Invalid atomic access index") \
332 T(InvalidCodePoint, "Invalid code point %") \
333 T(InvalidCountValue, "Invalid count value") \
334 T(InvalidDataViewAccessorOffset, \
335 "Offset is outside the bounds of the DataView") \
336 T(InvalidDataViewLength, "Invalid DataView length %") \
337 T(InvalidOffset, "Start offset % is outside the bounds of the buffer") \
338 T(InvalidHint, "Invalid hint: %") \
339 T(InvalidIndex, "Invalid value: not (convertible to) a safe integer") \
340 T(InvalidLanguageTag, "Invalid language tag: %") \
341 T(InvalidWeakMapKey, "Invalid value used as weak map key") \
342 T(InvalidWeakSetValue, "Invalid value used in weak set") \
343 T(InvalidStringLength, "Invalid string length") \
344 T(InvalidTimeValue, "Invalid time value") \
345 T(InvalidTimeZone, "Invalid time zone specified: %") \
346 T(InvalidTypedArrayAlignment, "% of % should be a multiple of %") \
347 T(InvalidTypedArrayIndex, "Invalid typed array index") \
348 T(InvalidTypedArrayLength, "Invalid typed array length: %") \
349 T(LetInLexicalBinding, "let is disallowed as a lexically bound name") \
350 T(LocaleMatcher, "Illegal value for localeMatcher:%") \
351 T(NormalizationForm, "The normalization form should be one of %.") \
352 T(ParameterOfFunctionOutOfRange, \
353 "Paramenter % of function %() is % and out of range") \
354 T(ZeroDigitNumericSeparator, \
355 "Numeric separator can not be used after leading 0.") \
356 T(NumberFormatRange, "% argument must be between 0 and 100") \
357 T(TrailingNumericSeparator, \
358 "Numeric separators are not allowed at the end of numeric literals") \
359 T(ContinuousNumericSeparator, \
360 "Only one underscore is allowed as numeric separator") \
361 T(PropertyValueOutOfRange, "% value is out of range.") \
362 T(StackOverflow, "Maximum call stack size exceeded") \
363 T(ToPrecisionFormatRange, \
364 "toPrecision() argument must be between 1 and 100") \
365 T(ToRadixFormatRange, "toString() radix argument must be between 2 and 36") \
366 T(TypedArraySetOffsetOutOfBounds, "offset is out of bounds") \
367 T(TypedArraySetSourceTooLarge, "Source is too large") \
368 T(TypedArrayTooLargeToSort, \
369 "Custom comparefn not supported for huge TypedArrays") \
370 T(ValueOutOfRange, "Value % out of range for % options property %") \
371 /* SyntaxError */ \
372 T(AmbiguousExport, \
373 "The requested module '%' contains conflicting star exports for name '%'") \
374 T(BadGetterArity, "Getter must not have any formal parameters.") \
375 T(BadSetterArity, "Setter must have exactly one formal parameter.") \
376 T(BigIntInvalidString, "Invalid BigInt string") \
377 T(ConstructorIsAccessor, "Class constructor may not be an accessor") \
378 T(ConstructorIsGenerator, "Class constructor may not be a generator") \
379 T(ConstructorIsAsync, "Class constructor may not be an async method") \
380 T(ConstructorIsPrivate, "Class constructor may not be a private method") \
381 T(DerivedConstructorReturnedNonObject, \
382 "Derived constructors may only return object or undefined") \
383 T(DuplicateConstructor, "A class may only have one constructor") \
384 T(DuplicateExport, "Duplicate export of '%'") \
385 T(DuplicateProto, \
386 "Duplicate __proto__ fields are not allowed in object literals") \
387 T(ForInOfLoopInitializer, \
388 "% loop variable declaration may not have an initializer.") \
389 T(ForOfLet, "The left-hand side of a for-of loop may not start with 'let'.") \
390 T(ForInOfLoopMultiBindings, \
391 "Invalid left-hand side in % loop: Must have a single binding.") \
392 T(GeneratorInSingleStatementContext, \
393 "Generators can only be declared at the top level or inside a block.") \
394 T(AsyncFunctionInSingleStatementContext, \
395 "Async functions can only be declared at the top level or inside a " \
396 "block.") \
397 T(IllegalBreak, "Illegal break statement") \
398 T(ModuleExportNameWithoutFromClause, \
399 "String literal module export names must be followed by a 'from' clause") \
400 T(NoIterationStatement, \
401 "Illegal continue statement: no surrounding iteration statement") \
402 T(IllegalContinue, \
403 "Illegal continue statement: '%' does not denote an iteration statement") \
404 T(IllegalLanguageModeDirective, \
405 "Illegal '%' directive in function with non-simple parameter list") \
406 T(IllegalReturn, "Illegal return statement") \
407 T(IntrinsicWithSpread, "Intrinsic calls do not support spread arguments") \
408 T(InvalidRestBindingPattern, \
409 "`...` must be followed by an identifier in declaration contexts") \
410 T(InvalidPropertyBindingPattern, "Illegal property in declaration context") \
411 T(InvalidRestAssignmentPattern, \
412 "`...` must be followed by an assignable reference in assignment " \
413 "contexts") \
414 T(InvalidEscapedReservedWord, "Keyword must not contain escaped characters") \
415 T(InvalidEscapedMetaProperty, "'%' must not contain escaped characters") \
416 T(InvalidLhsInAssignment, "Invalid left-hand side in assignment") \
417 T(InvalidCoverInitializedName, "Invalid shorthand property initializer") \
418 T(InvalidDestructuringTarget, "Invalid destructuring assignment target") \
419 T(InvalidLhsInFor, "Invalid left-hand side in for-loop") \
420 T(InvalidLhsInPostfixOp, \
421 "Invalid left-hand side expression in postfix operation") \
422 T(InvalidLhsInPrefixOp, \
423 "Invalid left-hand side expression in prefix operation") \
424 T(InvalidModuleExportName, \
425 "Invalid module export name: contains unpaired surrogate") \
426 T(InvalidRegExpFlags, "Invalid flags supplied to RegExp constructor '%'") \
427 T(InvalidOrUnexpectedToken, "Invalid or unexpected token") \
428 T(InvalidPrivateBrand, "Object must be an instance of class %") \
429 T(InvalidPrivateFieldResolution, \
430 "Private field '%' must be declared in an enclosing class") \
431 T(InvalidPrivateMemberRead, \
432 "Cannot read private member % from an object whose class did not declare " \
433 "it") \
434 T(InvalidPrivateMemberWrite, \
435 "Cannot write private member % to an object whose class did not declare " \
436 "it") \
437 T(InvalidPrivateMethodWrite, "Private method '%' is not writable") \
438 T(InvalidPrivateGetterAccess, "'%' was defined without a getter") \
439 T(InvalidPrivateSetterAccess, "'%' was defined without a setter") \
440 T(InvalidUnusedPrivateStaticMethodAccessedByDebugger, \
441 "Unused static private method '%' cannot be accessed at debug time") \
442 T(JsonParseUnexpectedEOS, "Unexpected end of JSON input") \
443 T(JsonParseUnexpectedToken, "Unexpected token % in JSON at position %") \
444 T(JsonParseUnexpectedTokenNumber, "Unexpected number in JSON at position %") \
445 T(JsonParseUnexpectedTokenString, "Unexpected string in JSON at position %") \
446 T(LabelRedeclaration, "Label '%' has already been declared") \
447 T(LabelledFunctionDeclaration, \
448 "Labelled function declaration not allowed as the body of a control flow " \
449 "structure") \
450 T(MalformedArrowFunParamList, "Malformed arrow function parameter list") \
451 T(MalformedRegExp, "Invalid regular expression: /%/: %") \
452 T(MalformedRegExpFlags, "Invalid regular expression flags") \
453 T(ModuleExportUndefined, "Export '%' is not defined in module") \
454 T(MissingFunctionName, "Function statements require a function name") \
455 T(HtmlCommentInModule, "HTML comments are not allowed in modules") \
456 T(MultipleDefaultsInSwitch, \
457 "More than one default clause in switch statement") \
458 T(NewlineAfterThrow, "Illegal newline after throw") \
459 T(NoCatchOrFinally, "Missing catch or finally after try") \
460 T(ParamAfterRest, "Rest parameter must be last formal parameter") \
461 T(FlattenPastSafeLength, \
462 "Flattening % elements on an array-like of length % " \
463 "is disallowed, as the total surpasses 2**53-1") \
464 T(PushPastSafeLength, \
465 "Pushing % elements on an array-like of length % " \
466 "is disallowed, as the total surpasses 2**53-1") \
467 T(ElementAfterRest, "Rest element must be last element") \
468 T(BadSetterRestParameter, \
469 "Setter function argument must not be a rest parameter") \
470 T(ParamDupe, "Duplicate parameter name not allowed in this context") \
471 T(ParenthesisInArgString, "Function arg string contains parenthesis") \
472 T(ArgStringTerminatesParametersEarly, \
473 "Arg string terminates parameters early") \
474 T(UnexpectedEndOfArgString, "Unexpected end of arg string") \
475 T(RestDefaultInitializer, \
476 "Rest parameter may not have a default initializer") \
477 T(RuntimeWrongNumArgs, "Runtime function given wrong number of arguments") \
478 T(SuperNotCalled, \
479 "Must call super constructor in derived class before accessing 'this' or " \
480 "returning from derived constructor") \
481 T(SingleFunctionLiteral, "Single function literal required") \
482 T(SloppyFunction, \
483 "In non-strict mode code, functions can only be declared at top level, " \
484 "inside a block, or as the body of an if statement.") \
485 T(SpeciesNotConstructor, \
486 "object.constructor[Symbol.species] is not a constructor") \
487 T(StrictDelete, "Delete of an unqualified identifier in strict mode.") \
488 T(StrictEvalArguments, "Unexpected eval or arguments in strict mode") \
489 T(StrictFunction, \
490 "In strict mode code, functions can only be declared at top level or " \
491 "inside a block.") \
492 T(StrictOctalLiteral, "Octal literals are not allowed in strict mode.") \
493 T(StrictDecimalWithLeadingZero, \
494 "Decimals with leading zeros are not allowed in strict mode.") \
495 T(StrictOctalEscape, \
496 "Octal escape sequences are not allowed in strict mode.") \
497 T(Strict8Or9Escape, "\\8 and \\9 are not allowed in strict mode.") \
498 T(StrictWith, "Strict mode code may not include a with statement") \
499 T(TemplateOctalLiteral, \
500 "Octal escape sequences are not allowed in template strings.") \
501 T(Template8Or9Escape, "\\8 and \\9 are not allowed in template strings.") \
502 T(ThisFormalParameter, "'this' is not a valid formal parameter name") \
503 T(AwaitBindingIdentifier, \
504 "'await' is not a valid identifier name in an async function") \
505 T(AwaitExpressionFormalParameter, \
506 "Illegal await-expression in formal parameters of async function") \
507 T(TooManyArguments, \
508 "Too many arguments in function call (only 65535 allowed)") \
509 T(TooManyParameters, \
510 "Too many parameters in function definition (only 65534 allowed)") \
511 T(TooManyProperties, "Too many properties to enumerate") \
512 T(TooManySpreads, \
513 "Literal containing too many nested spreads (up to 65534 allowed)") \
514 T(TooManyVariables, "Too many variables declared (only 4194303 allowed)") \
515 T(TooManyElementsInPromiseCombinator, \
516 "Too many elements passed to Promise.%") \
517 T(TypedArrayTooShort, \
518 "Derived TypedArray constructor created an array which was too small") \
519 T(UnexpectedEOS, "Unexpected end of input") \
520 T(UnexpectedPrivateField, "Unexpected private field") \
521 T(UnexpectedReserved, "Unexpected reserved word") \
522 T(UnexpectedStrictReserved, "Unexpected strict mode reserved word") \
523 T(UnexpectedSuper, "'super' keyword unexpected here") \
524 T(UnexpectedNewTarget, "new.target expression is not allowed here") \
525 T(UnexpectedTemplateString, "Unexpected template string") \
526 T(UnexpectedToken, "Unexpected token '%'") \
527 T(UnexpectedTokenUnaryExponentiation, \
528 "Unary operator used immediately before exponentiation expression. " \
529 "Parenthesis must be used to disambiguate operator precedence") \
530 T(UnexpectedTokenIdentifier, "Unexpected identifier") \
531 T(UnexpectedTokenNumber, "Unexpected number") \
532 T(UnexpectedTokenString, "Unexpected string") \
533 T(UnexpectedTokenRegExp, "Unexpected regular expression") \
534 T(UnexpectedLexicalDeclaration, \
535 "Lexical declaration cannot appear in a single-statement context") \
536 T(UnknownLabel, "Undefined label '%'") \
537 T(UnresolvableExport, \
538 "The requested module '%' does not provide an export named '%'") \
539 T(UnterminatedArgList, "missing ) after argument list") \
540 T(UnterminatedRegExp, "Invalid regular expression: missing /") \
541 T(UnterminatedTemplate, "Unterminated template literal") \
542 T(UnterminatedTemplateExpr, "Missing } in template expression") \
543 T(FoundNonCallableHasInstance, "Found non-callable @@hasInstance") \
544 T(InvalidHexEscapeSequence, "Invalid hexadecimal escape sequence") \
545 T(InvalidUnicodeEscapeSequence, "Invalid Unicode escape sequence") \
546 T(UndefinedUnicodeCodePoint, "Undefined Unicode code-point") \
547 T(YieldInParameter, "Yield expression not allowed in formal parameter") \
548 /* EvalError */ \
549 T(CodeGenFromStrings, "%") \
550 T(NoSideEffectDebugEvaluate, "Possible side-effect in debug-evaluate") \
551 /* URIError */ \
552 T(URIMalformed, "URI malformed") \
553 /* Wasm errors (currently Error) */ \
554 T(WasmTrapUnreachable, "unreachable") \
555 T(WasmTrapMemOutOfBounds, "memory access out of bounds") \
556 T(WasmTrapUnalignedAccess, "operation does not support unaligned accesses") \
557 T(WasmTrapDivByZero, "divide by zero") \
558 T(WasmTrapDivUnrepresentable, "divide result unrepresentable") \
559 T(WasmTrapRemByZero, "remainder by zero") \
560 T(WasmTrapFloatUnrepresentable, "float unrepresentable in integer range") \
561 T(WasmTrapTableOutOfBounds, "table index is out of bounds") \
562 T(WasmTrapFuncSigMismatch, "function signature mismatch") \
563 T(WasmTrapMultiReturnLengthMismatch, "multi-return length mismatch") \
564 T(WasmTrapJSTypeError, "type incompatibility when transforming from/to JS") \
565 T(WasmTrapDataSegmentDropped, "data segment has been dropped") \
566 T(WasmTrapElemSegmentDropped, "element segment has been dropped") \
567 T(WasmTrapBrOnExnNull, "br_on_exn on null value") \
568 T(WasmTrapRethrowNull, "rethrowing null value") \
569 T(WasmTrapNullDereference, "dereferencing a null pointer") \
570 T(WasmTrapIllegalCast, "illegal cast") \
571 T(WasmTrapArrayOutOfBounds, "array element access out of bounds") \
572 T(WasmExceptionError, "wasm exception") \
573 /* Asm.js validation related */ \
574 T(AsmJsInvalid, "Invalid asm.js: %") \
575 T(AsmJsCompiled, "Converted asm.js to WebAssembly: %") \
576 T(AsmJsInstantiated, "Instantiated asm.js: %") \
577 T(AsmJsLinkingFailed, "Linking failure in asm.js: %") \
578 /* DataCloneError messages */ \
579 T(DataCloneError, "% could not be cloned.") \
580 T(DataCloneErrorOutOfMemory, "Data cannot be cloned, out of memory.") \
581 T(DataCloneErrorDetachedArrayBuffer, \
582 "An ArrayBuffer is detached and could not be cloned.") \
583 T(DataCloneErrorSharedArrayBufferTransferred, \
584 "A SharedArrayBuffer could not be cloned. SharedArrayBuffer must not be " \
585 "transferred.") \
586 T(DataCloneDeserializationError, "Unable to deserialize cloned data.") \
587 T(DataCloneDeserializationVersionError, \
588 "Unable to deserialize cloned data due to invalid or unsupported " \
589 "version.") \
590 /* Builtins-Trace Errors */ \
591 T(TraceEventCategoryError, "Trace event category must be a string.") \
592 T(TraceEventNameError, "Trace event name must be a string.") \
593 T(TraceEventNameLengthError, \
594 "Trace event name must not be an empty string.") \
595 T(TraceEventPhaseError, "Trace event phase must be a number.") \
596 T(TraceEventIDError, "Trace event id must be a number.") \
597 /* Weak refs */ \
598 T(WeakRefsUnregisterTokenMustBeObject, \
599 "unregisterToken ('%') must be an object") \
600 T(WeakRefsCleanupMustBeCallable, \
601 "FinalizationRegistry: cleanup must be callable") \
602 T(WeakRefsRegisterTargetMustBeObject, \
603 "FinalizationRegistry.prototype.register: target must be an object") \
604 T(WeakRefsRegisterTargetAndHoldingsMustNotBeSame, \
605 "FinalizationRegistry.prototype.register: target and holdings must not " \
606 "be same") \
607 T(WeakRefsWeakRefConstructorTargetMustBeObject, \
608 "WeakRef: target must be an object") \
609 T(OptionalChainingNoNew, "Invalid optional chain from new expression") \
610 T(OptionalChainingNoSuper, "Invalid optional chain from super property") \
611 T(OptionalChainingNoTemplate, "Invalid tagged template on optional chain") \
612 /* AggregateError */ \
613 T(AllPromisesRejected, "All promises were rejected")
614
615 enum class MessageTemplate {
616 #define TEMPLATE(NAME, STRING) k##NAME,
617 MESSAGE_TEMPLATES(TEMPLATE)
618 #undef TEMPLATE
619 kMessageCount
620 };
621
MessageTemplateFromInt(int message_id)622 inline MessageTemplate MessageTemplateFromInt(int message_id) {
623 DCHECK_LT(static_cast<unsigned>(message_id),
624 static_cast<unsigned>(MessageTemplate::kMessageCount));
625 return static_cast<MessageTemplate>(message_id);
626 }
627
628 } // namespace internal
629 } // namespace v8
630
631 #endif // V8_COMMON_MESSAGE_TEMPLATE_H_
632