diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/MethodCallInfo.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/MethodCallInfo.java index 12582cc63..cc53ec2d4 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/MethodCallInfo.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/MethodCallInfo.java @@ -305,7 +305,18 @@ public class MethodCallInfo { */ public void validate() { if (resolvedMethod == null) { - setError(ErrorType.UNRESOLVED_METHOD, "Cannot resolve method '" + methodName + "'"); + if (isConstructor) { + // For constructors, check if the type has any constructors at all + if (receiverType != null && receiverType.hasConstructors()) { + setError(ErrorType.WRONG_ARG_COUNT, + "No constructor in '" + methodName + "' matches " + arguments.size() + " argument(s)"); + } else { + setError(ErrorType.UNRESOLVED_METHOD, + "Cannot resolve constructor for '" + methodName + "'"); + } + } else { + setError(ErrorType.UNRESOLVED_METHOD, "Cannot resolve method '" + methodName + "'"); + } return; } diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/ScriptDocument.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/ScriptDocument.java index 1ca326445..bd0458c13 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/ScriptDocument.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/ScriptDocument.java @@ -3378,18 +3378,17 @@ public class ScriptDocument { List arguments = parseMethodArguments(openParen + 1, closeParen); int argCount = arguments.size(); - if (info.hasConstructors()) { - MethodInfo constructor = info.findConstructor(argCount); - if (constructor != null) { - // Create MethodCallInfo for constructor - MethodCallInfo ctorCall = MethodCallInfo.constructor( - info, constructor, start, end, openParen, closeParen, arguments - ); - ctorCall.validate(); - marks.add(new ScriptLine.Mark(start, end, info.getTokenType(), ctorCall)); - continue; - } - } + // Try to find matching constructor (may be null if not found) + MethodInfo constructor = info.hasConstructors() ? info.findConstructor(argCount) : null; + + // Create MethodCallInfo for constructor (even if null, so errors are tracked) + MethodCallInfo ctorCall = MethodCallInfo.constructor( + info, constructor, start, end, openParen, closeParen, arguments + ); + ctorCall.validate(); + methodCalls.add(ctorCall); // Add to methodCalls list for error tracking + marks.add(new ScriptLine.Mark(start, end, info.getTokenType(), ctorCall)); + continue; } } } diff --git a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/hover/TokenHoverInfo.java b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/hover/TokenHoverInfo.java index 16d9e6e1c..9f342c9d6 100644 --- a/src/main/java/noppes/npcs/client/gui/util/script/interpreter/hover/TokenHoverInfo.java +++ b/src/main/java/noppes/npcs/client/gui/util/script/interpreter/hover/TokenHoverInfo.java @@ -171,7 +171,7 @@ public class TokenHoverInfo { MethodCallInfo callInfo = token.getMethodCallInfo(); if (callInfo != null) { if (callInfo.hasArgCountError()) { - errors.add("Expected " + getExpectedArgCount(callInfo) + " argument(s) but found " + callInfo.getArguments().size()); + errors.add(callInfo.getErrorMessage()); } if (callInfo.hasArgTypeError()) { for (MethodCallInfo.ArgumentTypeError error : callInfo.getArgumentTypeErrors()) {