Closed inferrna closed 1 month ago
Case 1 was fixed, now says error: no version of function "help" takes 1 arguments
Case 2 is as I would expect it.. how would you like this error to be different?
Note that Lobster typechecks each function based on the caller, in this case the caller is expecting there to be 3 return values, and it comes across a return statement only returning 2, and flags that as an error.
This is also an optimization: if you call a function ignoring a return value, it will compile that function in a way that it doesn't even generate that return value.
I was ok with case 1, but now error message is even better, thanks. Case 2: look to the line numbers.
Comparing to case 1, case 2 complains about function itself instead of caller.
To see case 2 in vscode this patch to be applied (relative to https://github.com/aardappel/lobster/pull/321 )
diff --git a/dev/lsp/src/lobster.ts b/dev/lsp/src/lobster.ts
index 4368a53..0202820 100644
--- a/dev/lsp/src/lobster.ts
+++ b/dev/lsp/src/lobster.ts
@@ -72,13 +72,13 @@ export async function parseLobster(
return []; // TODO make "can't open file" a normal error instead of an unformatted error
}
- const regex = /^(.*)\((\d+)\): (warning|error): (.*)/g;
+ const regex = /^(.*)\((\d+)\): (warning|error): (.*)/gm;
let match;
const output: Diagnostic[] = [];
while ((match = regex.exec(input))) {
const at = match[1];
- if (!file.endsWith(at)) return [];
+ //if (!file.endsWith(at)) return [];
const line = parseInt(match[2]) - 1; // Its zero based
const messageType = match[3].trim();
Read my explanation in the last message.
The way the language works, the function is the problem, not the caller :)
Whatever, I sort of fixed it on LSP side, will ship after https://github.com/aardappel/lobster/pull/321.
let a, b, c = help(2)
let a, b, c = help(2,1)