LuaValue, FuncState: correct error messages to match Lua

This commit is contained in:
gamax92
2019-08-11 11:50:42 +02:00
committed by asie
parent af4cfe5e00
commit c9fa0f27c7
2 changed files with 3 additions and 3 deletions

View File

@@ -1053,7 +1053,7 @@ public class LuaValue extends Varargs {
* @param expected String naming the type that was expected * @param expected String naming the type that was expected
* @throws LuaError in all cases * @throws LuaError in all cases
*/ */
protected LuaValue argerror(String expected) { throw new LuaError("bad argument: "+expected+" expected, got "+typename()); } protected LuaValue argerror(String expected) { throw new LuaError("bad argument ("+expected+" expected, got "+typename()+")"); }
/** /**
* Throw a {@link LuaError} indicating an invalid argument was supplied to a function * Throw a {@link LuaError} indicating an invalid argument was supplied to a function
@@ -1061,7 +1061,7 @@ public class LuaValue extends Varargs {
* @param msg String providing information about the invalid argument * @param msg String providing information about the invalid argument
* @throws LuaError in all cases * @throws LuaError in all cases
*/ */
public static LuaValue argerror(int iarg,String msg) { throw new LuaError("bad argument #"+iarg+": "+msg); } public static LuaValue argerror(int iarg,String msg) { throw new LuaError("bad argument #"+iarg+" ("+msg+")"); }
/** /**
* Throw a {@link LuaError} indicating an invalid type was supplied to a function * Throw a {@link LuaError} indicating an invalid type was supplied to a function

View File

@@ -97,7 +97,7 @@ public class FuncState extends Constants {
for (i = bl.firstlabel; i < ll_n; i++) { for (i = bl.firstlabel; i < ll_n; i++) {
if (label.eq_b(ll[i].name)) { if (label.eq_b(ll[i].name)) {
String msg = ls.L.pushfstring( String msg = ls.L.pushfstring(
"label '" + label + " already defined on line " + ll[i].line); "label '" + label + "' already defined on line " + ll[i].line);
ls.semerror(msg); ls.semerror(msg);
} }
} }