diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-05-05 00:01:14 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-05-05 00:01:14 +0200 |
| commit | ee818304f360d67f28726f907eed2df38c1c8ea9 (patch) | |
| tree | 3aba376d97280c35f61a8c536307311995442d3a /src | |
| parent | f2505b096d7367e4a6aa66475cda81e9f9bc0dae (diff) | |
fix invalid JSON when an error does not have a position
Diffstat (limited to 'src')
| -rw-r--r-- | src/error.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/error.cpp b/src/error.cpp index 1b091f88e..14b0ce7b7 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -728,9 +728,8 @@ gb_internal void print_all_errors(void) { } res = gb_string_append_fmt(res, "\",\n"); - res = gb_string_append_fmt(res, "\t\t\t\"pos\": {\n"); - if (ev.pos.file_id) { + res = gb_string_append_fmt(res, "\t\t\t\"pos\": {\n"); res = gb_string_append_fmt(res, "\t\t\t\t\"file\": \""); String file = get_file_path_string(ev.pos.file_id); for (isize k = 0; k < file.len; k++) { @@ -743,6 +742,8 @@ gb_internal void print_all_errors(void) { i32 end_column = gb_max(ev.end.column, ev.pos.column); res = gb_string_append_fmt(res, "\t\t\t\t\"end_column\": %d\n", end_column); res = gb_string_append_fmt(res, "\t\t\t},\n"); + } else { + res = gb_string_append_fmt(res, "\t\t\t\"pos\": null,\n"); } res = gb_string_append_fmt(res, "\t\t\t\"msgs\": [\n"); |