@@ -13987,10 +13987,10 @@ fn lowerAstErrors(astgen: *AstGen) !void {
13987
13987
const tok = parse_err.token + @intFromBool(parse_err.token_is_prev);
13988
13988
const tok_start = token_starts[tok];
13989
13989
13990
- if (token_tags[tok] == .invalid and tree.source[tok_start] == '\\') {
13990
+ if (token_tags[tok] == .invalid and (tree.source[tok_start] == '\\' or tree.source[tok_start] == '/')) {
13991
+ const tok_len: u32 = @intCast(tree.tokenSlice(tok).len);
13992
+ const tok_end = tok_start + tok_len;
13991
13993
const bad_off = blk: {
13992
- const tok_len: u32 = @intCast(tree.tokenSlice(tok).len);
13993
- const tok_end = tok_start + tok_len;
13994
13994
var idx = tok_start;
13995
13995
while (idx < tok_end) : (idx += 1) {
13996
13996
switch (tree.source[idx]) {
@@ -14005,10 +14005,20 @@ fn lowerAstErrors(astgen: *AstGen) !void {
14005
14005
try notes.append(gpa, try astgen.errNoteTokOff(tok, bad_off, "invalid byte: '{'}'", .{
14006
14006
std.zig.fmtEscapes(tree.source[byte_abs..][0..1]),
14007
14007
}));
14008
+ const expected_tag = switch (tree.source[tok_start]) {
14009
+ '\\' => std.zig.Token.Tag.multiline_string_literal_line,
14010
+ '/' => blk: {
14011
+ if (std.mem.indexOf(u8, tree.source[tok_start..tok_end], "///")) |idx| {
14012
+ if (idx == 0) break :blk std.zig.Token.Tag.doc_comment;
14013
+ }
14014
+ break :blk std.zig.Token.Tag.comment;
14015
+ },
14016
+ else => unreachable,
14017
+ };
14008
14018
const err: Ast.Error = .{
14009
14019
.tag = Ast.Error.Tag.expected_token,
14010
14020
.token = tok,
14011
- .extra = .{ .expected_tag = std.zig.Token.Tag.multiline_string_literal_line },
14021
+ .extra = .{ .expected_tag = expected_tag },
14012
14022
};
14013
14023
msg.clearRetainingCapacity();
14014
14024
try tree.renderError(err, msg.writer(gpa));
0 commit comments