Repository navigation
fix(hy-check): reject shadowed lowering packages os, filepath, and fmt in fmt.print and main wrapper (Row 13 BUILDABLE) - #3727
Merged
limitlessprojects merged 1 commit intoNov 6, 2026
Conversation
seenorht
force-pushed
the
fix/shadowed-lowering-os-filepath-soundness
branch
13 times, most recently
from
November 5, 2026 12:22
429ab60 to
37ceeab
Compare
seenorht
force-pushed
the
fix/shadowed-lowering-os-filepath-soundness
branch
4 times, most recently
from
November 5, 2026 20:16
e5e47f8 to
8413b8a
Compare
…t in fmt.print and main wrapper (Row 13 BUILDABLE)
seenorht
force-pushed
the
fix/shadowed-lowering-os-filepath-soundness
branch
from
November 5, 2026 20:17
8413b8a to
821020f
Compare
Owner
Landed: merged to main as the merge of
|
| Gate | Result |
|---|---|
| Merge gate | clean, head tree 88e2da18 |
| cargo test --workspace | 440 suites ok, 0 failed |
| Corpus harness | verdict agreement 135/135, tripwire not fired |
| Differential loop FULL | accept-side 45/45 build+run, reject-side 90/90 |
What landed
fn mainneeding the error/exit wrapper (non-empty results ortryin body) now rejects whenos/filepath/fmtare shadowed — the wrapper lowers toos.Exit/os.Stderr/filepath.Base/fmt.Fprintln, and none of those exist under a shadowed name.fmt.printbyte-slice/[]u8argument soundness viaslice_element_type_name,io.read_allbyte return via Field callee,Tryoperand element typing.- 271-line pinning suite
shadowed_lowering_os_filepath_soundness.rs.
The shadow-rename fixits make each rejection actionable; the wrapper-need gate (results or block_has_try) keeps the check from over-firing on plain mains.
Bounty: recorded per BOUNTY.md / discussion #295.
This was referenced Nov 6, 2026
2 tasks done
limitlessprojects
pushed a commit
that referenced
this pull request
Nov 6, 2026
…et/post, pin E11 ? propagation (fixes #3789) (bradwue313) buildable.rs: httptest.get/post calls now reject when `strings` or `http` is shadowed by an in-scope declaration (HYB-E1002 at the call span, is_pkg_symbol_shadowed) — both lower to strings.TrimSuffix / http.NewRequest (Row 13 BUILDABLE, following the #3598/#3614/#3727 shadow-package pattern). New suite shadowed_httptest_and_e11_handler_3789 (7 tests) also pins the existing E11 ? propagation behavior: shadowed `http` or response-writer param at a ? site inside http.handler rejects with HYB-E2011; unshadowed positive control accepts. In-merge fixture fixup (credited): the PR's patch replaced 10 UTF-8 arrows in unrelated doc comments (8 x U+2192, 2 x U+2194 -> literal ?) and appended a stray EOF blank line; all restored byte-identical to prior main inside this merge. Net change: +25 check lines + 85-line test file only. Verification (battery on trial-merge worktree vs main @ 973453c): merge-gate CLEAN; cargo test --workspace 457 suites ok; corpus 135/135 tripwire not fired; differential 45/45 accept + 90/90 reject FULL AGREEMENT. CREDIT: @bradwue313
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.
Summary
Under GUARANTEES.md Row 13 (BUILDABLE):
Following the maintainer's observation on #3598 (where shadowing
oscausedfmt.eprint*lowering tofmt.Fprint*(os.Stderr, ...)to fail downstream compilation), there are two other lowering paths inhy-emitthat inject unqualified package calls without import guarding inhy-check:fmt.printon byte slices ([]byte):In
hy-emit/src/expr.rs:1555:fmt.printon a byte buffer lowers toos.Stdout.Write(b).When
osis shadowed by an in-scope parameter, local binding, loop variable, closure argument, or package-level symbol, emitted Go producesos.Stdout undefinedor type mismatch undergo build.fn main()with error return or?operator:In
hy-emit/src/lib.rs:1545:When
mainreturns an error or contains?,hy-emitwraps the main function and injects:fmt.Fprintln(os.Stderr, filepath.Base(os.Args[0])+":", hyErr)os.Exit(1)oros.Exit(code)When
os,filepath, orfmtis shadowed in-scope by a package-level declaration, parameter, or constant, emitted Go fails downstream compilation becauseos.Exit,os.Stderr,filepath.Base, orfmt.Fprintlnresolves to the shadowing user symbol.Both patterns were accepted by
hy-checkwithVerdict::Acceptand failed downstreamgo build.Reproducer Matrix
hy-checkbeforego buildhy-checkaftervar os int = 0; fn main() { b := "hi".bytes(); fmt.print(b) }Acceptos.Stdout.Write(b)os.Stdout undefinedReject(HYB-E1002)var os int = 0; fn main() error { return errors.new("err") }Acceptfmt.Fprintln(os.Stderr...); os.Exit(1)os.Stderr undefinedReject(HYB-E1002)var filepath string = ""; fn main() error { return errors.new("err") }Acceptfilepath.Base(os.Args[0])cannot call non-function filepath.BaseReject(HYB-E1002)var fmt int = 1; fn main() error { return errors.new("err") }Acceptfmt.Fprintln(...)fmt.Fprintln undefinedReject(HYB-E1002)var os int = 0; fn main() { _ = os.open("x")? }Acceptos.Exit(1)os.Exit undefinedReject(HYB-E1002)Fix
In
compiler/crates/hy-check/src/buildable.rs:fmt.printbyte slice check:Extended the built-in call check on
pkg == "fmt"to inspectname == "print"with single slice-of-byte argument whenis_os_shadowed(), emittingHYB-E1002.fn main()lowering check:In
fn_decl, whenname == "main"and the function returns an error/exit code or its body contains?(main_needs_wrapper), checkis_os_shadowed(),is_filepath_shadowed(), andis_fmt_shadowed(). If any lowering package is shadowed, emitHYB-E1002diagnostic explaining that the error wrapper requires access toos,filepath, andfmt.is_pkg_symbol_shadowed,is_filepath_shadowed, andis_fmt_shadowed.block_has_try,stmt_has_try,place_has_try,expr_has_try) to detect?insidefn main().Verification
compiler/crates/hy-check/tests/shadowed_lowering_os_filepath_soundness.rscovering:os,filepath, andfmtinfmt.print(bytes)and error-returning /?-usingfn main().fmt.print(bytes), normal error-returningfn main(), and non-errorfn main()with localosvariable pass cleanly.tools/check_conflict_markers.py: OK (none)tools/check_test_registration.py: OK (38 test files, 35 discovery patterns)tools/check_guarantees.py: OK (table, registry, corpus and doc agree)Bounty payout coordinate (BOUNTY.md / discussion #295):
USDC (Base):
0x2fbD90378ACb304b4c474B433bf1Ea041EcB4290