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