Skip to content

Conversation

@dbrattli
Copy link
Collaborator

@dbrattli dbrattli commented Dec 7, 2025

Summary

  • Fixed incorrect hasSpread flag usage for String.Concat in Python Replacements
  • Simplified Rust concat implementation to accept varargs of strings directly
  • Updated type stub to match the new signature
  • Reverted linting changes to pyproject.toml that got removed by mistake

Problem

When transpiling F# code like:

let cssNew = $$""".{{classAttr}}:hover {background-color: #eee;}"""

The generated Python code was:

concat(".", "item-panel", *":hover {background-color: #eee;}")

The * spread operator was incorrectly applied to the last string argument, which would spread the string into individual characters. This happened to work because strings are iterable in Python and the characters would be joined back together, but it was inefficient and semantically incorrect.

Solution

  • Removed hasSpread = true from the String.Concat case in Python Replacements - the arguments should be passed directly without spreading
  • Simplified the Rust concat function from a complex implementation handling iterables to a simple varargs join
  • Updated the .pyi type stub to reflect the correct signature

Generated code after fix

concat(".", "item-panel", ":hover {background-color: #eee;}")

@dbrattli dbrattli merged commit 5b2ffac into main Dec 7, 2025
22 checks passed
@dbrattli dbrattli deleted the python-string-concat branch December 7, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants