chore(python): cover overloaded-ctor casing on lowercase types#4811
Merged
Conversation
Contributor
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
Follow-up to #4807. Add a regression test for the overload-suffix casing path on a lowercase type name: an overloaded constructor is emitted as a module-level name (`shape__ctor_z<hash>`) and imported across files, so the declaration and the import must agree on the suffix casing, not just the base name. The existing `type shape` has a single constructor and so never exercised the suffix path. Also expand the comments in `getMemberDeclarationName` to describe what the unconditional `toPythonNaming` on the composed name actually does: it mirrors the re-casing applied at import/reference sites (keeping declarations and references consistent), but as a side effect overrides the [<CompiledName>] skip for root-level compiled names that start lowercase and thus have no uppercase entity/module prefix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dbrattli
force-pushed
the
fix/python-type-name-casing-followup
branch
from
July 17, 2026 18:26
65304dd to
c0b6d06
Compare
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.
Follow-up to #4807.
1. Regression test for the overload-suffix casing path
#4807 fixed Python class/member declarations and references disagreeing on casing for lowercase-named types, but its test (
type shapewith a single constructor) never exercised the overload-suffix path called out in the PR description (shape__ctor_Z524259A4declared butshape__ctor_z524259a4imported).This gives
shapea second, overloaded constructor and references both across files. Transpiled output confirms declaration and import agree on the lowercased suffix:Before the #4807 fix, the declaration kept
...Z524259A4while the import used...z524259a4→ImportError.2. Accurate comments on the composed-name
toPythonNamingWhile reviewing the double
toPythonNamingapplication ingetMemberDeclarationName, I traced (via quicktest) exactly what the unconditional outer call does:[<CompiledName>]members. This is a no-op for class/nested-module members (uppercase entity/module prefix), so their compiled name survives — but a root-level[<CompiledName>]function starting lowercase gets snake_cased ([<CompiledName("rootLevelCompiled")>]→root_level_compiled).This is a pre-existing tension, not something this PR changes: cross-file references to such a function were already broken before #4807 (
ImportError), so #4807 traded "compiled name honored but cross-file broken" for "always consistent but not honored verbatim". A fully correct fix would need the import printer to beCompiledName-aware (it only sees a bare string today) — out of scope here. This PR just documents the real behavior instead of the earlier misleading "idempotent, harmless" note.No compiler behavior change — comments only.
Testing
./build.sh test python— all 2405 tests pass (run against the initial version of this PR; item 2 is comments-only).🤖 Generated with Claude Code