Skip to content

Commit 0c26030

Browse files
committed
fix(native): fix parity divergence in extract_inline_new_type
Use strip_prefix('(').unwrap_or(receiver) instead of trim_start_matches('(') to strip at most one leading paren, matching the JS regex ^\(?. Also update the doc comment to reflect that _ and $ prefixes are also accepted.
1 parent 654532c commit 0c26030

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

crates/codegraph-core/src/edge_builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,10 +506,10 @@ fn resolve_call_targets<'a>(
506506
/// Handles `(new Foo)` and `(new Foo('arg'))` receivers that arise when the call site
507507
/// is `(new Foo).method()` without a named variable binding.
508508
///
509-
/// Only extracts PascalCase (uppercase-initial) names to avoid false positives on
510-
/// lowercase constructor calls (rare but present in legacy code).
509+
/// Only extracts names that start with an uppercase letter, `_`, or `$` to avoid
510+
/// false positives on plain lowercase constructor calls (rare but present in legacy code).
511511
fn extract_inline_new_type(receiver: &str) -> Option<String> {
512-
let s = receiver.trim_start_matches('(').trim_start();
512+
let s = receiver.strip_prefix('(').unwrap_or(receiver).trim_start();
513513
let s = s.strip_prefix("new")?;
514514
if !s.starts_with(|c: char| c.is_whitespace()) { return None; }
515515
let s = s.trim_start();

0 commit comments

Comments
 (0)