Skip to content

Commit a1b848a

Browse files
authored
Merge pull request #1288 from sogaiu/more-error-loc-info-in-dobytes
Report line and col more in janet_dobytes
2 parents dbcc1fa + a23c03f commit a1b848a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/core/run.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,20 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
5757
}
5858
} else {
5959
ret = janet_wrap_string(cres.error);
60+
int32_t line = (int32_t) parser.line;
61+
int32_t col = (int32_t) parser.column;
62+
if ((cres.error_mapping.line > 0) &&
63+
(cres.error_mapping.column > 0)) {
64+
line = cres.error_mapping.line;
65+
col = cres.error_mapping.column;
66+
}
6067
if (cres.macrofiber) {
61-
janet_eprintf("compile error in %s: ", sourcePath);
68+
janet_eprintf("%s:%d:%d: compile error", sourcePath,
69+
line, col);
6270
janet_stacktrace_ext(cres.macrofiber, ret, "");
6371
} else {
64-
janet_eprintf("compile error in %s: %s\n", sourcePath,
65-
(const char *)cres.error);
72+
janet_eprintf("%s:%d:%d: compile error: %s\n", sourcePath,
73+
line, col, (const char *)cres.error);
6674
}
6775
errflags |= 0x02;
6876
done = 1;

0 commit comments

Comments
 (0)