diff --git a/src/core/errors.go b/src/core/errors.go index fa31fb9..e8a4a98 100644 --- a/src/core/errors.go +++ b/src/core/errors.go @@ -29,6 +29,10 @@ type DefinitionCountMismatch struct { func (err *DefinitionCountMismatch) Error() string { if err.Count > err.ExpectedCount { + if err.ExpectedCount == 0 { + return fmt.Sprintf("'%s' does not have a return value", err.Function) + } + return fmt.Sprintf("Too many variables for the return value of '%s'", err.Function) } diff --git a/src/core/errors_test.go b/src/core/errors_test.go index 31b2bf9..d4fb522 100644 --- a/src/core/errors_test.go +++ b/src/core/errors_test.go @@ -17,6 +17,7 @@ var errs = []struct { }{ {"DefinitionCountMismatch.q", &core.DefinitionCountMismatch{Function: "main.swap", Count: 1, ExpectedCount: 2}}, {"DefinitionCountMismatch2.q", &core.DefinitionCountMismatch{Function: "main.swap", Count: 3, ExpectedCount: 2}}, + {"DefinitionCountMismatch3.q", &core.DefinitionCountMismatch{Function: "main.nothing", Count: 1, ExpectedCount: 0}}, {"ErrorNotChecked.q", &core.ErrorNotChecked{Identifier: "value"}}, {"InvalidCallExpression.q", core.InvalidCallExpression}, {"InvalidCondition.q", core.InvalidCondition}, diff --git a/src/core/testdata/DefinitionCountMismatch3.q b/src/core/testdata/DefinitionCountMismatch3.q new file mode 100644 index 0000000..f8a80e9 --- /dev/null +++ b/src/core/testdata/DefinitionCountMismatch3.q @@ -0,0 +1,5 @@ +main() { + a := nothing() +} + +nothing() {} \ No newline at end of file