fix crash on multiline library name
This commit is contained in:
parent
50754ba336
commit
af2ede4d96
@ -285,7 +285,12 @@ fn parseTopLevelDecl(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node
|
||||
|
||||
if (extern_export_inline_token) |token| {
|
||||
if (lib_name) |string_literal_node|
|
||||
putBackToken(it, string_literal_node.cast(Node.StringLiteral).?.token);
|
||||
if (string_literal_node.cast(Node.StringLiteral)) |single| {
|
||||
putBackToken(it, single.token);
|
||||
} else if (string_literal_node.cast(Node.MultilineStringLiteral)) |multi| {
|
||||
while (multi.lines.pop()) |line|
|
||||
putBackToken(it, line);
|
||||
} else unreachable;
|
||||
putBackToken(it, token);
|
||||
return null;
|
||||
}
|
||||
|
@ -2721,6 +2721,16 @@ test "zig fmt: extern without container keyword returns error" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: extern multiline lib name" {
|
||||
try testError(
|
||||
\\extern \\super
|
||||
\\ \\long
|
||||
\\ \\library
|
||||
\\ \\name
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
const warn = std.debug.warn;
|
||||
|
Loading…
x
Reference in New Issue
Block a user