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