Skip to content

Commit eb37dd3

Browse files
committed
partially fix for #1343: multi-param function call
1 parent 20922f4 commit eb37dd3

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/com/goide/inspections/GoFunctionCallInspection.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,19 @@ public void visitCallExpr(@NotNull GoCallExpr o) {
5656
expectedSize += size == 0 ? 1 : size;
5757
}
5858

59-
if (expectedSize != actualSize) {
60-
if (actualSize == 1) {
61-
GoExpression first = ContainerUtil.getFirstItem(list);
62-
PsiReference firstRef = GoPsiImplUtil.getCallReference(first);
63-
PsiElement firstResolve = firstRef != null ? firstRef.resolve() : null;
64-
if (firstResolve instanceof GoFunctionOrMethodDeclaration) {
65-
int resultCount = GoInspectionUtil.getFunctionResultCount((GoFunctionOrMethodDeclaration)firstResolve);
66-
if (resultCount == expectedSize) return;
67-
}
59+
if (actualSize == 1) {
60+
GoExpression first = ContainerUtil.getFirstItem(list);
61+
PsiReference firstRef = GoPsiImplUtil.getCallReference(first);
62+
PsiElement firstResolve = firstRef != null ? firstRef.resolve() : null;
63+
if (firstResolve instanceof GoFunctionOrMethodDeclaration) {
64+
actualSize = GoInspectionUtil.getFunctionResultCount((GoFunctionOrMethodDeclaration)firstResolve);
6865
}
69-
70-
String tail = " arguments in call to " + expression.getText();
71-
holder.registerProblem(o.getArgumentList(), actualSize > expectedSize ? "too many" + tail : "not enough" + tail);
7266
}
67+
68+
if (actualSize == expectedSize) return;
69+
70+
String tail = " arguments in call to " + expression.getText();
71+
holder.registerProblem(o.getArgumentList(), actualSize > expectedSize ? "too many" + tail : "not enough" + tail);
7372
}
7473
}
7574
}

testData/highlighting/funcCall.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,15 @@ func demo23(a *d, err error) string {
134134

135135
func <warning>main23</warning>() {
136136
_ = demo23(de("1").Func())
137+
}
138+
139+
func foo_m(_ int) {
140+
}
141+
142+
func bar_m() (int, int) {
143+
return 0, 0
144+
}
145+
146+
func <warning>main127</warning>() {
147+
foo_m<error>(bar_m())</error>
137148
}

0 commit comments

Comments
 (0)