[BUG] TUI crashes on `constructor.hpp` with `(r||"").toLowerCase is not a function`
Status Fixed / completed
Reported on v2.1.87
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 5 comments · opened Mar 29, 2026 · closed Apr 10, 2026
Preflight Checklist
- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Claude Code's TUI crashes when it tries to create, write, or edit a file named constructor.hpp.
At first this looked workspace-specific, because I first encountered it in a few repositories. After further testing, I was able to narrow it down much more:
- Files such as
constructor2.hpp,constructor_copy.hpp, andtmp.hppdo not trigger the crash - A file named
constructor.hppdoes trigger the crash - This reproduces in different environments, not just one local workspace
- The problem appears tied to the filename and the write/edit path in the TUI, rather than to the original repository contents
I can reproduce this even with a minimal file named constructor.hpp.
What Should Happen?
Claude Code should be able to create, write, and edit a file named constructor.hpp without crashing the TUI.
Error Messages/Logs
The key error at the beginning is:
```text id="1pab8y"
ERROR (r||"").toLowerCase is not a function. (In '(r||"").toLowerCase()', '(r||"").toLowerCase' is undefined)
/$bunfs/root/src/entrypoints/cli.js:1438:2089
Part of the stack trace near the end:
```text id="2m2jj0"
- g (/$bunfs/root/src/entrypoints/cli.js:1438:2089)
- nGK (/$bunfs/root/src/entrypoints/cli.js:1717:10107)
- render (/$bunfs/root/src/entrypoints/cli.js:1719:2254)
- Qz1 (/$bunfs/root/src/entrypoints/cli.js:1722:1456)
- <anonymous> (/$bunfs/root/src/entrypoints/cli.js:1722:2115)
- $D (/$bunfs/root/src/entrypoints/cli.js:452:20997)
- _z (/$bunfs/root/src/entrypoints/cli.js:452:39538)
- UH (/$bunfs/root/src/entrypoints/cli.js:452:36907)
- xH (/$bunfs/root/src/entrypoints/cli.js:452:36434)
- Hs (/$bunfs/root/src/entrypoints/cli.js:452:52627)
Steps to Reproduce
Minimal reproduction pattern:
- Start Claude Code in a fresh folder or fresh session.
- Ask Claude Code to create a file named
constructor.hpp. - Use minimal contents such as:
```cpp id="q3sd9a"
#pragma once
struct A {};
4. The TUI crashes during the write step.
I can also reproduce the crash when editing a file named `constructor.hpp`.
Control cases that do **not** crash:
1. Create or edit `constructor2.hpp` with the same minimal contents.
2. Create or edit `constructor_copy.hpp` with the same minimal contents.
3. Create or edit `tmp.hpp` with the same minimal contents.
These control cases work normally, which makes me suspect this is specifically related to the filename `constructor.hpp`.
### Claude Model
Opus
### Is this a regression?
Yes, this worked in a previous version.
### Last Working Version
*No response*
### Claude Code Version
2.1.87 (Claude Code)
### Platform
Anthropic API
### Operating System
Windows and Linux
### Terminal/Shell
WSL on Windows locally, and also reproduced in a separate Linux server environment
### Additional Information
Additional narrowing I did:
* Initially this looked repository-specific
* Moving the project to a new directory did not help
* Clearing caches did not help
* Deleting Claude Code's local project state did not help
* I checked for encoding issues, suspicious characters, BOM, zero-width characters, bidi control characters, and similar issues across the codebase and did not find anything
* I tested copies of the original file under different names, and those did not crash
* I tested the same filename in a different directory, and it still crashed
* I tested a minimal `constructor.hpp` file, and it still crashed
At this point, the issue seems strongly tied to the filename `constructor.hpp` during the TUI write/edit flow, rather than to file contents, encoding, inode identity, or a specific repository.
If helpful, I can provide more step-by-step reproduction notes.
5 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
I dug into this further and found a likely root cause.
This appears to be an inherited-property bug in the filename/stem-to-language lookup used during diff or syntax-highlighting.
For filenames like
constructor.hpp, the stemconstructorcan resolve to the inheritedObject.prototype.constructorwhen a plain object is used as a dictionary. That non-string value then flows into the language-detection path and eventually triggers:(r||"").toLowerCase is not a functionThis likely affects other inherited property names too, such as:
toString.*valueOf.*hasOwnProperty.*__proto__.*Suggested fix:
Object.create(null), orAlso experiencing this on macOS (Darwin 25.2.0). The crash happens consistently when resuming after an interrupted response, especially in longer conversations with Go code.
Stack trace is identical:
Been hitting this for ~3 days. The workaround of giving specific instructions instead of "continue" sometimes helps, but it's not reliable.
Seems to occur with any file that has the name constructor in it:
TUI crash:
(r||"").toLowerCase is not a functionwhen editing files namedconstructor.*Summary
Claude Code crashes when rendering diffs for files whose basename (before the extension) matches an
Object.prototypeproperty name, most commonlyconstructor. The crash occurs in the syntax highlighting language detection code.Version
Steps to reproduce
constructor.py(orconstructor.js,constructor.rs, etc.)Minimal repro:
Error
Root cause
The
XsKfunction detects the syntax highlighting language from a file path. It uses a plain objectYsKas a filename-to-language map:The lookup logic extracts the basename without extension and checks the map:
Since
YsKis a plain{},YsK["constructor"]resolves toObject.prototype.constructor(the built-inObjectfunction) via prototype chain lookup. This is a truthy non-string value, so it passes the guardif (f && ...)and is forwarded tohljs.getLanguage(), which calls.toLowerCase()on it and crashes.Affected filenames
Any file whose name before the first
.matches anObject.prototypeproperty:constructor.py(most common in practice)toString.jsvalueOf.tshasOwnProperty.goSuggested fix
Replace the plain object with
Object.create(null)to prevent prototype chain lookups:Or add a
hasOwnPropertyguard:Workaround
Disable syntax highlighting:
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.