Restore method recognition after C++ constructor bodies by jnohclee-rgb · Pull Request #3395 · pygments/pygments · GitHub
Skip to content

Restore method recognition after C++ constructor bodies - #3395

Open
jnohclee-rgb wants to merge 1 commit into
pygments:masterfrom
jnohclee-rgb:dharma-cpp-after-constructor
Open

jnohclee-rgb wants to merge 1 commit into
pygments:masterfrom
jnohclee-rgb:dharma-cpp-after-constructor

Conversation

@jnohclee-rgb

Copy link
Copy Markdown

After an unrecognized C++ constructor body, the generic statement state can remain active across its closing brace. The following member declaration is then highlighted as ordinary names: struct point { point() {} int dim() const { return 1; } }; loses dim's Name.Function classification.

Return the C++ statement state to its parent at a closing brace. The shared C rules are unchanged. Add a narrow inherited Pike case-label guard so recovered function bodies preserve existing case-colon punctuation. Updated C++, CUDA, MQL and Pike goldens recover method/function names; two local direct-initialization variables (returnStr and dimBlock) correctly become ordinary names.

Related to #2547, specifically its remaining constructor/member case. The template-return case belongs to the separate open #3361 and is not fixed here.

Validation: 15 focused tests pass (seven fail on the original modules; eight preservation cases pass). Full tox -e py: 5,345 passed, 16 skipped. tox -e check passes. Existing environments were reused with installation disabled and this worktree explicitly on PYTHONPATH. Independent review accepted the source and golden changes, reran all 15 focused cases, and passed four additional declaration/context cases.

AI assistance: Codex assisted with implementation, testing and review. No compiler validation or optional regexlint/version matrix was run.

Dharma — leave the code kinder than we found it.

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.

1 participant