show newt failure in vscode

This commit is contained in:
2024-09-14 21:55:27 -07:00
parent ac7a61e1fd
commit b65a76ccd3
4 changed files with 12 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ I may be done with `U` - I keep typing `Type`.
- have separate type of implict with `{{}}`
- [ ] do blocks
- [ ] some solution for `+` problem (classes? ambiguity?)
- [ ] show compiler failure in the editor (exit code != 0)
- [x] show compiler failure in the editor (exit code != 0)
- [ ] write js files into `out` directory
- [ ] detect extra clauses in case statements
- [ ] add test framework

View File

@@ -17,6 +17,7 @@ export function activate(context: vscode.ExtensionContext) {
const cmd = config.get<string>("path", "build/exec/newt");
const command = `${cmd} ${fileName}`;
exec(command, { cwd }, (err, stdout, _stderr) => {
// I think I ignored 1 here because I wanted failure to launch
if (err && err.code !== 1) {
vscode.window.showErrorMessage(`newt error: ${err}`);
}
@@ -25,6 +26,14 @@ export function activate(context: vscode.ExtensionContext) {
const lines = stdout.split("\n");
const diagnostics: vscode.Diagnostic[] = [];
if (err) {
let start = new vscode.Position(0,0)
let end = new vscode.Position(0,1)
let range = document.getWordRangeAtPosition(start) ?? new vscode.Range(start,end)
const diag = new vscode.Diagnostic(range, "newt execution failed", vscode.DiagnosticSeverity.Error)
diagnostics.push(diag)
}
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
const match = line.match(/(INFO|ERROR) at \((\d+), (\d+)\): (.*)/);

View File

@@ -16,7 +16,7 @@
},
{
"name": "keyword.newt",
"match": "\\b(data|where|case|of|let|in|U|module|ptype|pfunc)\\b"
"match": "\\b(data|where|case|of|let|in|U|module|ptype|pfunc|infix|infixl|infixr)\\b"
}
]
}

View File

@@ -650,7 +650,7 @@ infer ctx (RPi fc nm icit ty ty2) = do
let nm := fromMaybe "_" nm
ty2' <- check (extend ctx nm vty') ty2 (VU fc)
pure (Pi fc nm icit ty' ty2', (VU fc))
infer ctx (RLet fc str tm tm1 tm2) = error fc "implement RLet"
infer ctx (RLet fc nm ty v sc) = error fc "implement RLet"
infer ctx (RAnn fc tm rty) = do
ty <- check ctx rty (VU fc)
vty <- eval ctx.env CBN ty