fix: parse explicit destructor calls with template-ids and qualified names#360
Open
edge90 wants to merge 2 commits into
Open
fix: parse explicit destructor calls with template-ids and qualified names#360edge90 wants to merge 2 commits into
edge90 wants to merge 2 commits into
Conversation
The destructor-id in an explicit destructor call may name a class template specialization, e.g. `p->~vector<int>()` or `p->~shared_ptr<const T>()`. `destructor_name` only allowed `~ identifier`, so any template-id after `~` produced an ERROR node. Allow an optional `template_argument_list` and add a GLR conflict for `destructor_name` to resolve the `<` (template-args vs less-than) ambiguity. A plain `~Name` is unchanged.
A qualified destructor-id in an explicit destructor call via `->`/`.`, e.g. `p->std::vector<int>::~vector()` or `p->A::~A()`, produced an ERROR node. `qualified_identifier` already accepts a trailing `destructor_name`, but `qualified_field_identifier` (the member-access path) did not; mirror it there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related fixes for explicit destructor calls (
p->~T()) that produceERRORnodes on valid C++. A destructor-id may name a class template specialization (asimple-template-idafter~), which is valid since C++98 (g++ -std=c++98 -pedantic-errorsaccepts the syntax; thestd::types in the examples are just C++11 library):1. Template-id destructor-name.
destructor_nameonly allowed~ identifier, so a destructor naming a class template specialization failed to parse:Fix: allow an optional
template_argument_list, with aconflictsentry fordestructor_nameso the parser explores both readings of the<(template arguments vs. less-than); the trailing()disambiguates.2. Qualified destructor calls.
qualified_identifieralready accepts a trailingdestructor_name, butqualified_field_identifier(the->/.member-access path) did not:Fix: add
destructor_nametoqualified_field_identifier, mirroringqualified_identifier.A plain
~Nameis unchanged. Corpus tests are added intest/corpus/expressions.txtand the fulltree-sitter testsuite passes.