Merge pull request #5032 from LakeByTheWoods/redo_translate_c

Translate C: Redo Add comment containing c source location for failed decls.
This commit is contained in:
Vexu
2020-05-16 17:37:19 +03:00
committed by GitHub
2 changed files with 13 additions and 9 deletions

View File

@@ -2332,8 +2332,10 @@ fn renderTokenOffset(
}
while (true) {
assert(loc.line != 0);
const newline_count = if (loc.line == 1) @as(u8, 1) else @as(u8, 2);
// translate-c doesn't generate correct newlines
// in generated code (loc.line == 0) so treat that case
// as though there was meant to be a newline between the tokens
const newline_count = if (loc.line <= 1) @as(u8, 1) else @as(u8, 2);
try stream.writeByteNTimes('\n', newline_count);
try stream.writeByteNTimes(' ', indent);
try stream.writeAll(mem.trimRight(u8, tree.tokenSlicePtr(next_token), " "));