Skip to content

Commit 7adea28

Browse files
committed
Fix crash on OCaml syntax error.
1 parent 375b7cb commit 7adea28

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Add command: ReScript: Restart Language Server
99
- Fix issue where the server would crash on genType's errors.
1010
- Extend integration with reanalyze for code analysis. Support both `dce` and `exception` analysis which can be configured to e.g. both run by adding `{"reanalyze": {"analysis": ["dce", "exception"]} }` in `bsconfig.json`.
11+
- Fix issue where the server would crash if the project contains an OCaml file with a syntax error.
1112

1213
## 1.3.0
1314

server/src/utils.ts

+13
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,19 @@ export let parseCompilerLogOutput = (
579579
) {
580580
// OCaml warning: skip
581581
i++;
582+
} else if (
583+
line.startsWith("File ") &&
584+
i + 1 < lines.length &&
585+
lines[i + 1].startsWith("Error: Syntax error")
586+
) {
587+
// OCaml Syntax Error
588+
parsedDiagnostics.push({
589+
code: undefined,
590+
severity: t.DiagnosticSeverity.Error,
591+
tag: undefined,
592+
content: [lines[i], lines[i+1]],
593+
});
594+
i++;
582595
} else if (/^ +([0-9]+| +|\.) (|)/.test(line)) {
583596
// ^^ indent
584597
// ^^^^^^^^^^^^^^^ gutter

0 commit comments

Comments
 (0)