1/*
2** VM error messages.
3** Copyright (C) 2005-2021 Mike Pall. See Copyright Notice in luajit.h
4*/
5
6/* This file may be included multiple times with different ERRDEF macros. */
7
8/* Basic error handling. */
9ERRDEF(ERRMEM, "not enough memory")
10ERRDEF(ERRERR, "error in error handling")
11ERRDEF(ERRCPP, "C++ exception")
12
13/* Allocations. */
14ERRDEF(STROV, "string length overflow")
15ERRDEF(UDATAOV, "userdata length overflow")
16ERRDEF(STKOV, "stack overflow")
17ERRDEF(STKOVM, "stack overflow (%s)")
18ERRDEF(TABOV, "table overflow")
19
20/* Table indexing. */
21ERRDEF(NANIDX, "table index is NaN")
22ERRDEF(NILIDX, "table index is nil")
23ERRDEF(NEXTIDX, "invalid key to " LUA_QL("next"))
24
25/* Metamethod resolving. */
26ERRDEF(BADCALL, "attempt to call a %s value")
27ERRDEF(BADOPRT, "attempt to %s %s " LUA_QS " (a %s value)")
28ERRDEF(BADOPRV, "attempt to %s a %s value")
29ERRDEF(BADCMPT, "attempt to compare %s with %s")
30ERRDEF(BADCMPV, "attempt to compare two %s values")
31ERRDEF(GETLOOP, "loop in gettable")
32ERRDEF(SETLOOP, "loop in settable")
33ERRDEF(OPCALL, "call")
34ERRDEF(OPINDEX, "index")
35ERRDEF(OPARITH, "perform arithmetic on")
36ERRDEF(OPCAT, "concatenate")
37ERRDEF(OPLEN, "get length of")
38
39/* Type checks. */
40ERRDEF(BADSELF, "calling " LUA_QS " on bad self (%s)")
41ERRDEF(BADARG, "bad argument #%d to " LUA_QS " (%s)")
42ERRDEF(BADTYPE, "%s expected, got %s")
43ERRDEF(BADVAL, "invalid value")
44ERRDEF(NOVAL, "value expected")
45ERRDEF(NOCORO, "coroutine expected")
46ERRDEF(NOTABN, "nil or table expected")
47ERRDEF(NOLFUNC, "Lua function expected")
48ERRDEF(NOFUNCL, "function or level expected")
49ERRDEF(NOSFT, "string/function/table expected")
50ERRDEF(NOPROXY, "boolean or proxy expected")
51ERRDEF(FORINIT, LUA_QL("for") " initial value must be a number")
52ERRDEF(FORLIM, LUA_QL("for") " limit must be a number")
53ERRDEF(FORSTEP, LUA_QL("for") " step must be a number")
54
55/* C API checks. */
56ERRDEF(NOENV, "no calling environment")
57ERRDEF(CYIELD, "attempt to yield across C-call boundary")
58ERRDEF(BADLU, "bad light userdata pointer")
59ERRDEF(NOGCMM, "bad action while in __gc metamethod")
60#if LJ_TARGET_WINDOWS
61ERRDEF(BADFPU, "bad FPU precision (use D3DCREATE_FPU_PRESERVE with DirectX)")
62#endif
63
64/* Standard library function errors. */
65ERRDEF(ASSERT, "assertion failed!")
66ERRDEF(PROTMT, "cannot change a protected metatable")
67ERRDEF(UNPACK, "too many results to unpack")
68ERRDEF(RDRSTR, "reader function must return a string")
69ERRDEF(PRTOSTR, LUA_QL("tostring") " must return a string to " LUA_QL("print"))
70ERRDEF(IDXRNG, "index out of range")
71ERRDEF(BASERNG, "base out of range")
72ERRDEF(LVLRNG, "level out of range")
73ERRDEF(INVLVL, "invalid level")
74ERRDEF(INVOPT, "invalid option")
75ERRDEF(INVOPTM, "invalid option " LUA_QS)
76ERRDEF(INVFMT, "invalid format")
77ERRDEF(SETFENV, LUA_QL("setfenv") " cannot change environment of given object")
78ERRDEF(CORUN, "cannot resume running coroutine")
79ERRDEF(CODEAD, "cannot resume dead coroutine")
80ERRDEF(COSUSP, "cannot resume non-suspended coroutine")
81ERRDEF(TABINS, "wrong number of arguments to " LUA_QL("insert"))
82ERRDEF(TABCAT, "invalid value (%s) at index %d in table for " LUA_QL("concat"))
83ERRDEF(TABSORT, "invalid order function for sorting")
84ERRDEF(IOCLFL, "attempt to use a closed file")
85ERRDEF(IOSTDCL, "standard file is closed")
86ERRDEF(OSUNIQF, "unable to generate a unique filename")
87ERRDEF(OSDATEF, "field " LUA_QS " missing in date table")
88ERRDEF(STRDUMP, "unable to dump given function")
89ERRDEF(STRSLC, "string slice too long")
90ERRDEF(STRPATB, "missing " LUA_QL("[") " after " LUA_QL("%f") " in pattern")
91ERRDEF(STRPATC, "invalid pattern capture")
92ERRDEF(STRPATE, "malformed pattern (ends with " LUA_QL("%") ")")
93ERRDEF(STRPATM, "malformed pattern (missing " LUA_QL("]") ")")
94ERRDEF(STRPATU, "unbalanced pattern")
95ERRDEF(STRPATX, "pattern too complex")
96ERRDEF(STRCAPI, "invalid capture index")
97ERRDEF(STRCAPN, "too many captures")
98ERRDEF(STRCAPU, "unfinished capture")
99ERRDEF(STRFMT, "invalid option " LUA_QS " to " LUA_QL("format"))
100ERRDEF(STRGSRV, "invalid replacement value (a %s)")
101ERRDEF(BADMODN, "name conflict for module " LUA_QS)
102#if LJ_HASJIT
103ERRDEF(JITPROT, "runtime code generation failed, restricted kernel?")
104ERRDEF(NOJIT, "JIT compiler disabled")
105#elif defined(LJ_ARCH_NOJIT)
106ERRDEF(NOJIT, "no JIT compiler for this architecture (yet)")
107#else
108ERRDEF(NOJIT, "JIT compiler permanently disabled by build option")
109#endif
110ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS)
111
112/* Lexer/parser errors. */
113ERRDEF(XMODE, "attempt to load chunk with wrong mode")
114ERRDEF(XNEAR, "%s near " LUA_QS)
115ERRDEF(XLINES, "chunk has too many lines")
116ERRDEF(XLEVELS, "chunk has too many syntax levels")
117ERRDEF(XNUMBER, "malformed number")
118ERRDEF(XLSTR, "unfinished long string")
119ERRDEF(XLCOM, "unfinished long comment")
120ERRDEF(XSTR, "unfinished string")
121ERRDEF(XESC, "invalid escape sequence")
122ERRDEF(XLDELIM, "invalid long string delimiter")
123ERRDEF(XTOKEN, LUA_QS " expected")
124ERRDEF(XJUMP, "control structure too long")
125ERRDEF(XSLOTS, "function or expression too complex")
126ERRDEF(XLIMC, "chunk has more than %d local variables")
127ERRDEF(XLIMM, "main function has more than %d %s")
128ERRDEF(XLIMF, "function at line %d has more than %d %s")
129ERRDEF(XMATCH, LUA_QS " expected (to close " LUA_QS " at line %d)")
130ERRDEF(XFIXUP, "function too long for return fixup")
131ERRDEF(XPARAM, "<name> or " LUA_QL("...") " expected")
132#if !LJ_52
133ERRDEF(XAMBIG, "ambiguous syntax (function call x new statement)")
134#endif
135ERRDEF(XFUNARG, "function arguments expected")
136ERRDEF(XSYMBOL, "unexpected symbol")
137ERRDEF(XDOTS, "cannot use " LUA_QL("...") " outside a vararg function")
138ERRDEF(XSYNTAX, "syntax error")
139ERRDEF(XFOR, LUA_QL("=") " or " LUA_QL("in") " expected")
140ERRDEF(XBREAK, "no loop to break")
141ERRDEF(XLUNDEF, "undefined label " LUA_QS)
142ERRDEF(XLDUP, "duplicate label " LUA_QS)
143ERRDEF(XGSCOPE, "<goto %s> jumps into the scope of local " LUA_QS)
144
145/* Bytecode reader errors. */
146ERRDEF(BCFMT, "cannot load incompatible bytecode")
147ERRDEF(BCBAD, "cannot load malformed bytecode")
148
149#if LJ_HASFFI
150/* FFI errors. */
151ERRDEF(FFI_INVTYPE, "invalid C type")
152ERRDEF(FFI_INVSIZE, "size of C type is unknown or too large")
153ERRDEF(FFI_BADSCL, "bad storage class")
154ERRDEF(FFI_DECLSPEC, "declaration specifier expected")
155ERRDEF(FFI_BADTAG, "undeclared or implicit tag " LUA_QS)
156ERRDEF(FFI_REDEF, "attempt to redefine " LUA_QS)
157ERRDEF(FFI_NUMPARAM, "wrong number of type parameters")
158ERRDEF(FFI_INITOV, "too many initializers for " LUA_QS)
159ERRDEF(FFI_BADCONV, "cannot convert " LUA_QS " to " LUA_QS)
160ERRDEF(FFI_BADLEN, "attempt to get length of " LUA_QS)
161ERRDEF(FFI_BADCONCAT, "attempt to concatenate " LUA_QS " and " LUA_QS)
162ERRDEF(FFI_BADARITH, "attempt to perform arithmetic on " LUA_QS " and " LUA_QS)
163ERRDEF(FFI_BADCOMP, "attempt to compare " LUA_QS " with " LUA_QS)
164ERRDEF(FFI_BADCALL, LUA_QS " is not callable")
165ERRDEF(FFI_NUMARG, "wrong number of arguments for function call")
166ERRDEF(FFI_BADMEMBER, LUA_QS " has no member named " LUA_QS)
167ERRDEF(FFI_BADIDX, LUA_QS " cannot be indexed")
168ERRDEF(FFI_BADIDXW, LUA_QS " cannot be indexed with " LUA_QS)
169ERRDEF(FFI_BADMM, LUA_QS " has no " LUA_QS " metamethod")
170ERRDEF(FFI_WRCONST, "attempt to write to constant location")
171ERRDEF(FFI_NODECL, "missing declaration for symbol " LUA_QS)
172ERRDEF(FFI_BADCBACK, "bad callback")
173#if LJ_OS_NOJIT
174ERRDEF(FFI_CBACKOV, "no support for callbacks on this OS")
175#else
176ERRDEF(FFI_CBACKOV, "too many callbacks")
177#endif
178ERRDEF(FFI_NYIPACKBIT, "NYI: packed bit fields")
179ERRDEF(FFI_NYICALL, "NYI: cannot call this C function (yet)")
180#endif
181
182#if LJ_HASBUFFER
183/* String buffer errors. */
184ERRDEF(BUFFER_BADENC, "cannot serialize " LUA_QS)
185ERRDEF(BUFFER_BADDEC, "cannot deserialize tag 0x%02x")
186ERRDEF(BUFFER_DEPTH, "too deep to serialize")
187ERRDEF(BUFFER_DUPKEY, "duplicate table key")
188ERRDEF(BUFFER_EOB, "unexpected end of buffer")
189ERRDEF(BUFFER_LEFTOV, "left-over data in buffer")
190#endif
191
192#undef ERRDEF
193
194/* Detecting unused error messages:
195 awk -F, '/^ERRDEF/ { gsub(/ERRDEF./, ""); printf "grep -q LJ_ERR_%s *.[ch] || echo %s\n", $1, $1}' lj_errmsg.h | sh
196*/
197