Fix NPE on error. #40

This commit is contained in:
Enyby
2019-05-05 17:22:24 +03:00
parent 16aa199d40
commit 7721380e20

View File

@@ -50,7 +50,6 @@ public class FuncState extends Constants {
Hashtable h; /* table to find (and reuse) elements in `k' */ Hashtable h; /* table to find (and reuse) elements in `k' */
FuncState prev; /* enclosing function */ FuncState prev; /* enclosing function */
LexState ls; /* lexical state */ LexState ls; /* lexical state */
LuaC.CompileState L; /* compiler being invoked */
BlockCnt bl; /* chain of current blocks */ BlockCnt bl; /* chain of current blocks */
int pc; /* next position to code (equivalent to `ncode') */ int pc; /* next position to code (equivalent to `ncode') */
int lasttarget; /* `pc' of last `jump target' */ int lasttarget; /* `pc' of last `jump target' */
@@ -113,8 +112,8 @@ public class FuncState extends Constants {
void errorlimit (int limit, String what) { void errorlimit (int limit, String what) {
// TODO: report message logic. // TODO: report message logic.
String msg = (f.linedefined == 0) ? String msg = (f.linedefined == 0) ?
L.pushfstring("main function has more than "+limit+" "+what) : ls.L.pushfstring("main function has more than "+limit+" "+what) :
L.pushfstring("function at line "+f.linedefined+" has more than "+limit+" "+what); ls.L.pushfstring("function at line "+f.linedefined+" has more than "+limit+" "+what);
ls.lexerror(msg, 0); ls.lexerror(msg, 0);
} }