claude-code - 💡(How to fix) Fix [BUG] The arrow -> in trailing return type syntax breaks C++ syntax highlighting [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46823Fetched 2026-04-12 13:32:09
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Error Message

Error Messages/Logs

RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

C++ syntax highlighting does not work for any block of code that contains a trailing return type due to the arrow: auto bar() -> int.

An arrow made with the same characters has other uses (e.g. as a member access operator), but the other uses do not break syntax highlighting.

What Should Happen?

C++ syntax highlighting should work when a trailing return type arrow appears in a code block.

Error Messages/Logs

Steps to Reproduce

Instruct Claude to output these lines as C++ code.

// breaks auto f() -> int { return 0; } auto f(int x) -> const char* { return "hi"; } auto f(int x, double y) -> std::vector<int> { return {}; }

// fine auto square = [](int x) -> int { return x * x; }; int g() { return 0; } int* ptr = nullptr; int val = ptr->x;

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.101

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

extent analysis

TL;DR

Update the syntax highlighting rules to correctly handle C++ trailing return types with arrows.

Guidance

  • Review the syntax highlighting configuration to ensure it accounts for the specific syntax of C++ trailing return types, such as auto bar() -> int.
  • Verify that the highlighting rules are not mistakenly interpreting the arrow as a member access operator.
  • Test the syntax highlighting with various C++ code blocks containing trailing return types to identify any patterns or edge cases that may be causing the issue.
  • Consider updating the Claude Code version or configuration if the issue persists, as the problem may be related to the specific version or settings being used.

Example

No specific code snippet is provided, but an example of a correctly highlighted C++ code block with a trailing return type would be:

auto foo() -> int { return 0; }

This should be highlighted as a valid C++ function declaration.

Notes

The issue may be specific to the Sonnet model or the Anthropic API, and further investigation may be needed to determine the root cause. Additionally, the lack of error messages or logs makes it difficult to provide a more specific solution.

Recommendation

Apply a workaround by updating the syntax highlighting rules to correctly handle C++ trailing return types with arrows, as this is the most likely cause of the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING