| author | |
| committer | |
| log | fb2569461182d62d297a69b1388c8328b9a56932 |
| tree | 27b20953db25face56d405b6627aac76ca344f6a |
| parent | 9303d4be1029dc42845aafeff38c811a08ac29b0 |
| signature |
/// should not be parsed as a division operator followed by a comment
if it appears in a context where a division operator is accepted.
Add the missing negative lookahead to the SLASH token.3 files changed, 6 insertions(+), 1 deletions(-)
doc/langref/grammar.peg+1-1| ... | @@ -537,7 +537,7 @@ RBRACE <- skip '}' | ... | @@ -537,7 +537,7 @@ RBRACE <- skip '}' |
| 537 | RBRACKET <- skip ']' | 537 | RBRACKET <- skip ']' |
| 538 | RPAREN <- skip ')' | 538 | RPAREN <- skip ')' |
| 539 | SEMICOLON <- skip ';' | 539 | SEMICOLON <- skip ';' |
| 540 | SLASH <- skip '/' ![=] | 540 | SLASH <- skip '/' ![=/] |
| 541 | SLASHEQUAL <- skip '/=' | 541 | SLASHEQUAL <- skip '/=' |
| 542 | TILDE <- skip '~' | 542 | TILDE <- skip '~' |
| 543 | 543 |
lib/std/zig/parser_fuzz.zig+4| ... | @@ -25,6 +25,10 @@ test "operator whitespace" { | ... | @@ -25,6 +25,10 @@ test "operator whitespace" { |
| 25 | \\} | 25 | \\} |
| 26 | ); | 26 | ); |
| 27 | } | 27 | } |
| 28 | // Found using AFL++ | ||
| 29 | test "doc comment or division operator" { | ||
| 30 | try checkAgainstOracle("0=0///\n0"); | ||
| 31 | } | ||
| 28 | 32 | ||
| 29 | fn checkAgainstOracle(source: [:0]const u8) !void { | 33 | fn checkAgainstOracle(source: [:0]const u8) !void { |
| 30 | var fba_buf: [1 << 18]u8 = undefined; | 34 | var fba_buf: [1 << 18]u8 = undefined; |
lib/std/zig/parser_generated_oracle.zig+1| ... | @@ -3927,6 +3927,7 @@ const Parser = struct { | ... | @@ -3927,6 +3927,7 @@ const Parser = struct { |
| 3927 | const pos_1 = p.i; | 3927 | const pos_1 = p.i; |
| 3928 | const match_1 = (p.i < p.source.len and switch (p.source[p.i]) { | 3928 | const match_1 = (p.i < p.source.len and switch (p.source[p.i]) { |
| 3929 | '='...'=', | 3929 | '='...'=', |
| 3930 | '/'...'/', | ||
| 3930 | => blk_2: { | 3931 | => blk_2: { |
| 3931 | p.i += 1; | 3932 | p.i += 1; |
| 3932 | break :blk_2 true; | 3933 | break :blk_2 true; |