1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-26 08:20:27 +00:00

Merge pull request #1288 from sogaiu/more-error-loc-info-in-dobytes

Report line and col more in janet_dobytes
This commit is contained in:
Calvin Rose 2023-09-14 08:21:52 -07:00 committed by GitHub
commit a1b848ad76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -57,12 +57,20 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
} }
} else { } else {
ret = janet_wrap_string(cres.error); ret = janet_wrap_string(cres.error);
int32_t line = (int32_t) parser.line;
int32_t col = (int32_t) parser.column;
if ((cres.error_mapping.line > 0) &&
(cres.error_mapping.column > 0)) {
line = cres.error_mapping.line;
col = cres.error_mapping.column;
}
if (cres.macrofiber) { if (cres.macrofiber) {
janet_eprintf("compile error in %s: ", sourcePath); janet_eprintf("%s:%d:%d: compile error", sourcePath,
line, col);
janet_stacktrace_ext(cres.macrofiber, ret, ""); janet_stacktrace_ext(cres.macrofiber, ret, "");
} else { } else {
janet_eprintf("compile error in %s: %s\n", sourcePath, janet_eprintf("%s:%d:%d: compile error: %s\n", sourcePath,
(const char *)cres.error); line, col, (const char *)cres.error);
} }
errflags |= 0x02; errflags |= 0x02;
done = 1; done = 1;