From 2c634778c3f6024dff47af6c7844e65af7ac060c Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sat, 6 Jan 2024 17:47:07 +0200 Subject: [PATCH] fix: report proper function name in String.length errors --- src/me/topchetoeu/jscript/lib/StringLib.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/me/topchetoeu/jscript/lib/StringLib.java b/src/me/topchetoeu/jscript/lib/StringLib.java index 65311b3..40d5941 100644 --- a/src/me/topchetoeu/jscript/lib/StringLib.java +++ b/src/me/topchetoeu/jscript/lib/StringLib.java @@ -37,14 +37,14 @@ public class StringLib { if (i < 0) i += len; if (clamp) { if (i < 0) i = 0; - if (i >= len) i = len; + if (i > len) i = len; } return i; } @Expose(type = ExposeType.GETTER) public static int __length(Arguments args) { - return passThis(args, "substring").length(); + return passThis(args, "length").length(); } @Expose public static String __substring(Arguments args) {