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