Repository navigation
be-py, be-rust: name a library with a digit the way python and cargo do - #616
Open
notactuallytreyanastasio wants to merge 1 commit into
Open
notactuallytreyanastasio wants to merge 1 commit into
notactuallytreyanastasio wants to merge 1 commit into
Conversation
A library named `f64str` or `radix-36` builds on py and rust, then
fails to run, because each backend refers to it by a name nothing
defines:
import f64_str as module
ModuleNotFoundError: No module named 'f64_str'
error[E0433]: cannot find module or crate `radix36` in this scope
2 | radix36::init(None).unwrap().run_all_blocking();
Both names came from `IdentStyle.Dash.convertTo(IdentStyle.Snake, ..)`.
That conversion re-splits the name into words, and it puts `_` after a
run of digits but never before one, so `f64str` becomes `f64_str` and
`radix-36` becomes `radix36`. It is the right tool for turning a
Temper identifier into a Python or Rust one, and the wrong one here,
where the name has to match what another tool already made of it.
py writes the package to a directory named by `toModuleFileName`
(`f64str`, `radix_36`), and imports of it from other libraries use
that too; only the `PyLibraryName` metadata, which `top.py` and the
REPL import, used `IdentStyle`. pyDirToLibraryName now uses
`toModuleFileName`.
cargo names a package's library crate by replacing each `-` with `_`.
`PackageNaming.crateName` now does exactly that. It is used for
`main.rs` and for paths into other crates, so a library that imports
from `radix-36` failed on rust the same way, with `radix36::`, and now
prints its result too. Module paths inside a crate still use
`dashToSnake`; they are declared and referred to by the same function.
Names with no digit come out as before: both conversions give
`hello_world` for `hello-world`.
PyIdentifierTest.libraryNameIsItsPackageDirectory and
RustNamesTest.crateNameIsCargos fail before this change on `f64str`
(`f64_str`) and pass after. `temper run` of `f64str`, `radix-36`, and a
library importing from `radix-36`, prints the expected lines on py and
rust.
Fixes temperlang#610.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Bobby Grayson <bobbbygrayson+github@gmail.com>
mikesamuel
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A library named
f64strorradix-36builds on py and rust, thenfails to run, because each backend refers to it by a name nothing
defines:
Both names came from
IdentStyle.Dash.convertTo(IdentStyle.Snake, ..).That conversion re-splits the name into words, and it puts
_after arun of digits but never before one, so
f64strbecomesf64_strandradix-36becomesradix36. It is the right tool for turning aTemper identifier into a Python or Rust one, and the wrong one here,
where the name has to match what another tool already made of it.
py writes the package to a directory named by
toModuleFileName(
f64str,radix_36), and imports of it from other libraries usethat too; only the
PyLibraryNamemetadata, whichtop.pyand theREPL import, used
IdentStyle. pyDirToLibraryName now usestoModuleFileName.cargo names a package's library crate by replacing each
-with_.PackageNaming.crateNamenow does exactly that. It is used formain.rsand for paths into other crates, so a library that importsfrom
radix-36failed on rust the same way, withradix36::, and nowprints its result too. Module paths inside a crate still use
dashToSnake; they are declared and referred to by the same function.Names with no digit come out as before: both conversions give
hello_worldforhello-world.PyIdentifierTest.libraryNameIsItsPackageDirectory and
RustNamesTest.crateNameIsCargos fail before this change on
f64str(
f64_str) and pass after.temper runoff64str,radix-36, and alibrary importing from
radix-36, prints the expected lines on py andrust.
Fixes #610.
Reproduction:
57-library-name-with-digit/in temper-issue-repros.🤖 Generated with Claude Code