check_rename refuses a Ruby predicate/bang name it indexes happily: new_name must be a plain identifier rejects foo? #295
Labels
No labels
code-review
correctness
dos
performance
security
severity/high
severity/low
severity/medium
tech-debt
Kind/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
h-dv/code-index#295
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Reported from a live Ruby project, reproduced here.
The measurement
The index stores the symbol with the
?:But renaming it to another perfectly ordinary Ruby predicate name is refused:
Why it matters
?and!suffixes are not exotic Ruby — they are the convention for predicates and for mutating/raising variants, and they appear on a large share of methods in any idiomatic Ruby codebase. The tool indexes those names correctly and then refuses to reason about renaming to one.The reporter also observed the second-order effect: with a plain name substituted,
check_renamefound both edit sites, but its text scan could not run on the?name, so the safety net that compensates for unresolved references was unavailable on exactly the methods where Ruby resolution is weakest (see #294). It reported that honestly rather than claiming a clean rename, which is the disclosure working — but the answer is still degraded for a name the language considers ordinary.Scope to establish before fixing
The validator should accept what each language accepts, not one lowest common denominator:
?and!; also=for setters (name=), and operator method names (<=>,[],[]=,+).$are the obvious places to check.Whatever shape the fix takes, the text scan must run on the accepted names too — a validator that admits
foo?while the scan silently skips it would move the blindness rather than remove it.Suggested acceptance
check_renameaccepts a name valid in the symbol's own language, and refuses with a message naming the language and what it allows.?,!and=measured rather than assumed.Found alongside #294 in the same Ruby dogfood. Lower severity than that one: this refuses loudly, where #294 answers confidently and wrongly.
Fixed in v0.31.2 (PR #299, commit
85bb486).lang_profile::IDENTIFIER_SUFFIXESgrants Ruby one trailing?,!or=, read throughprofile_nameso the packagedde.h-dv.ruby/rubyid gets the same answer (the #112 trap).check_renamechecks shape first and then the symbol's own language;text_occurrencesno longer goes dark on those names, since?,!and=are literal inside an FTS5 phrase.On the reported case,
issued_for_us?→mcp_client_token?now finds both edit sites with every evidence channelclear, the text channel included. A Rust symbol still refusesvalid?, with a message naming its language. Three mutations were run, each red on its named test.Not changed: renaming to a Ruby operator method (
<=>,[]=) is still refused. That was out of scope and remains a loud refusal, not a silent one.