Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions codeflash/languages/java/remove_asserts.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,12 @@ def _find_balanced_parens(self, code: str, open_paren_pos: int) -> tuple[str | N
string_char = None
in_char = False

while pos < len(code) and depth > 0:
code_len = len(code)
# Initialize prev_char to match original behavior where prev_char = code[pos - 1]
prev_char = code[open_paren_pos] if open_paren_pos < code_len else ""

while pos < code_len and depth > 0:
char = code[pos]
prev_char = code[pos - 1] if pos > 0 else ""

# Handle character literals
if char == "'" and not in_string and prev_char != "\\":
Expand All @@ -661,6 +664,8 @@ def _find_balanced_parens(self, code: str, open_paren_pos: int) -> tuple[str | N

pos += 1

prev_char = char

if depth != 0:
return None, -1

Expand Down
Loading