Skip to content

Commit 0e5ad41

Browse files
committed
Merge remote-tracking branch 'origin/multi-language' into multi-language
2 parents c9cd7bc + 828d99d commit 0e5ad41

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

codeflash/languages/javascript/instrument.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,11 @@ def _parse_standalone_call(self, code: str, match: re.Match) -> StandaloneCallMa
203203
prefix = match.group(2) or "" # "await " or ""
204204
object_prefix = match.group(3) or "" # Object prefix like "calc." or ""
205205

206+
# If qualified_name is a standalone function (no dot), don't match method calls
207+
# e.g., if qualified_name="func", don't match "obj.func()" - only match "func()"
208+
if "." not in self.qualified_name and object_prefix:
209+
return None
210+
206211
# Find the opening paren position
207212
match_text = match.group(0)
208213
paren_offset = match_text.rfind("(")
@@ -390,6 +395,11 @@ def _parse_expect_call(self, code: str, match: re.Match) -> ExpectCallMatch | No
390395
leading_ws = match.group(1)
391396
object_prefix = match.group(2) or "" # Object prefix like "calc." or ""
392397

398+
# If qualified_name is a standalone function (no dot), don't match method calls
399+
# e.g., if qualified_name="func", don't match "obj.func()" - only match "func()"
400+
if "." not in self.qualified_name and object_prefix:
401+
return None
402+
393403
# Find the arguments of the function call (handling nested parens)
394404
args_start = match.end()
395405
func_args, func_close_pos = self._find_balanced_parens(code, args_start - 1)

0 commit comments

Comments
 (0)