Improve error message for string.char.

This commit is contained in:
Enyby
2018-09-16 15:09:36 +03:00
committed by GitHub
parent 0a5cccc50f
commit 5bd9827af1

View File

@@ -154,7 +154,7 @@ public class StringLib extends TwoArgFunction {
byte[] bytes = new byte[n]; byte[] bytes = new byte[n];
for ( int i=0, a=1; i<n; i++, a++ ) { for ( int i=0, a=1; i<n; i++, a++ ) {
int c = args.checkint(a); int c = args.checkint(a);
if (c<0 || c>=256) argerror(a, "invalid value"); if (c<0 || c>=256) argerror(a, "invalid value for string.char [0; 255]: " + c);
bytes[i] = (byte) c; bytes[i] = (byte) c;
} }
return LuaString.valueUsing( bytes ); return LuaString.valueUsing( bytes );