mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 07:32:44 +00:00
return a valid node even if invalid deref was used
This commit is contained in:
parent
d7f9128b5d
commit
a63fd34c50
@ -2701,11 +2701,17 @@ const Parser = struct {
|
||||
return &node.base;
|
||||
}
|
||||
|
||||
if (p.token_ids[p.tok_i] == .Invalid_periodasterisks) {
|
||||
if (p.eatToken(.Invalid_periodasterisks)) |period_asterisk| {
|
||||
try p.errors.append(p.gpa, .{
|
||||
.AsteriskAfterPointerDereference = .{ .token = p.tok_i },
|
||||
.AsteriskAfterPointerDereference = .{ .token = period_asterisk },
|
||||
});
|
||||
return null;
|
||||
const node = try p.arena.allocator.create(Node.SimpleSuffixOp);
|
||||
node.* = .{
|
||||
.base = .{ .tag = .Deref },
|
||||
.lhs = lhs,
|
||||
.rtoken = period_asterisk,
|
||||
};
|
||||
return &node.base;
|
||||
}
|
||||
|
||||
if (p.eatToken(.Period)) |period| {
|
||||
|
@ -226,7 +226,14 @@ test "recovery: invalid asterisk after pointer dereference" {
|
||||
\\}
|
||||
, &[_]Error{
|
||||
.AsteriskAfterPointerDereference,
|
||||
.ExpectedToken,
|
||||
});
|
||||
try testError(
|
||||
\\test "" {
|
||||
\\ var sequence = "repeat".** 10&&a;
|
||||
\\}
|
||||
, &[_]Error{
|
||||
.AsteriskAfterPointerDereference,
|
||||
.InvalidAnd,
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user