Skip to content

fix(syntax): allow Parser to be reused - #1394

Open
jaideeppyne wants to merge 1 commit into
rust-lang:masterfrom
jaideeppyne:fix/parser-reuse
Open

jaideeppyne wants to merge 1 commit into
rust-lang:masterfrom
jaideeppyne:fix/parser-reuse

Conversation

@jaideeppyne

Copy link
Copy Markdown

`Parser::parse` panicked on the second call because `parse_with_comments` asserted `offset == 0` before calling `reset()`.

Reset first, and also clear `capture_index`, `capture_names`, and `scratch` so a reused parser does not leak capture numbering or names from the previous pattern.

Fixes #1392

reset() ran after an assertion that offset was still 0, so a second
parse always panicked. Reset first, and also clear capture index,
capture names, and scratch so reuse starts from a clean parser.

Fixes rust-lang#1392

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(syntax): Panic when Parser is used twice

1 participant