Repository navigation
Conversation
…ns (limitlessprojects#607) `stats := (pool_stats{hits: 1})` binds exactly what `stats := pool_stats{hits: 1}` binds, but `register_var_ty` matched `values.first()` directly, so the struct type never reached `var_struct`. With no type the shape table cannot resolve `stats.mu` to `sync.mutex`, and the field call emits Go's lowercase spelling: $ hyb check p.hy -> OK (0 diagnostics) $ hyb build p.hy -> emitted stats.mu.lock() $ go build stats.mu.lock undefined (type "sync".Mutex has no field or method lock, but does have method Lock) An accepted program that does not build (rule BUILDABLE). This is the remaining leg of limitlessprojects#607. The other leg - `mux := (http.new_serve_mux())` losing its foreign binding kind - is already fixed on main: `binding_kind_of` now peels at entry, and that reproducer emits `mux.Handle(...)` today. So this revision carries only the `register_var_ty` peel; the earlier `binding_kind_of` hunk is dropped rather than re-proposed, and the corresponding test stays as a pin. Verified on aa4a9d9: `cargo test -p hy-emit` 186 passed / 0 failed (184 before, +2). With the `stmt.rs` hunk reverted and only the tests kept, exactly `struct_binding_type_registers_through_redundant_parentheses` fails and the other 185 pass; `foreign_binding_kind_survives_redundant_ parentheses` is green either way, which is why it is labelled a pin. End-to-end on the Go toolchain: the reproducer emits `stats.mu.Lock()` / `stats.mu.Unlock()`, builds, and prints `hits: 2`. Known local-only failure, not from this change: `hyb --bin hyb tests::generate_one_ignores_stale_generated_hy_go_siblings_on_package_ rename` fails identically on an untouched tree in this environment (non-ASCII %TEMP% / path handling in `hyb generate`).
Leimiu-G
force-pushed
the
fix/emit-binding-kind-parens
branch
from
October 19, 2026 00:39
971ea25 to
104f3ac
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.
Fixes #607 — the remaining leg.
What
stats := (pool_stats{hits: 1})binds exactly whatstats := pool_stats{hits: 1}binds, butregister_var_tymatchedvalues.first()directly, so the struct type never reachedvar_struct.With no type the shape table cannot resolve
stats.mutosync.mutex, and the field call emits Go'slowercase spelling:
An accepted program that does not build — rule
BUILDABLE/ corpus contract.The fix is one
peel_parenson the value that decides the binding's type:Scope note — why this revision is smaller than the first one
#607 lists two reproducers. Reproducer 1 is already fixed on
main:binding_kind_ofnow peelsat entry, so
mux := (http.new_serve_mux())emitsmux.Handle(...)today:So the
binding_kind_ofhunk from my first revision is dropped instead of re-proposed, and itstest is kept only as a pin (it is green with and without this change — stated in the test's comment so
it does not read as coverage it does not provide).
I also re-checked the
Try-operand leg (f := (os.open(x))?thenf.close()) onaa4a9d9: bothspellings emit
f.Close(), so no peel is needed there either. One line is the whole fix.Verification (on
aa4a9d9)Falsifiable: with the
stmt.rshunk reverted and both tests kept, exactly one fails and the other185 pass:
End-to-end, past the Rust tests to the Go toolchain and the running binary:
go buildstats := pool_stats{hits: 1}stats.mu.Lock()hits: 2stats := (pool_stats{hits: 1})stats.mu.Lock()hits: 2Both spellings now produce byte-identical Go.
Known local-only failure, not from this change:
cargo test --workspaceshowshyb --bin hyb tests::generate_one_ignores_stale_generated_hy_go_siblings_on_package_renamefailing.It fails identically on an untouched tree in this environment (
hyb generate+ non-ASCII%TEMP%),which I confirmed against a clean checkout before reporting this PR.
Related
Same invariant as the merged #611 (
hy-syntax) and #631 (hy-emit), and the report #618:Parenisdocumented as span-only, so every site that reads the shape of an expression has to look through it.