Skip to content

Commit

Permalink
Fix f str handling
Browse files Browse the repository at this point in the history
  • Loading branch information
evhub committed May 12, 2024
1 parent 34f1381 commit b2c4e5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion coconut/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4339,7 +4339,7 @@ def f_string_handle(self, original, loc, tokens):
expr_rstrip = expr.rstrip()
if expr_rstrip.endswith("="):
before = string_parts[i]
string_parts[i] = assert_remove_prefix(before, "{") + expr + "{"
string_parts[i] = assert_remove_suffix(before, "{") + expr + "{"
exprs[i] = assert_remove_suffix(expr_rstrip, "=")

# compile Coconut expressions
Expand Down
4 changes: 2 additions & 2 deletions coconut/tests/src/cocotest/agnostic/primary_2.coco
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,8 @@ def primary_test_2() -> bool:
assert py_min(3, 4) == 3 == py_max(2, 3)
assert len(zip()) == 0 == len(zip_longest()) # type: ignore
assert CoconutWarning `issubclass` Warning
a = b = 2
assert f"{a + b = }" == "a + b = 4"
x = y = 2
assert f"{x + y = }" == "x + y = 4"

with process_map.multiple_sequential_calls(): # type: ignore
assert map((+), range(3), range(4)$[:-1], strict=True) |> list == [0, 2, 4] == process_map((+), range(3), range(4)$[:-1], strict=True) |> list # type: ignore
Expand Down

0 comments on commit b2c4e5f

Please sign in to comment.