You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hy-check: reject shadowed strings/http in httptest and shadowed http/writer in http.handler (fixes #3789) - #3794
Any program accepted by hyb check must emit Go code that compiles under go build.
Following the pattern established for shadowed packages (os, filepath, fmt in #3598, #3614, and #3727), two lowering paths in hy-emit emit calls to imported standard library packages or rely on parameter identifiers without scope verification in hy-check:
httptest.get and httptest.post lowering (hy-emit/src/stmt.rs:1244-1267):
Lowers to http.NewRequest(...), httptest.NewRecorder(), and strings.TrimSuffix(...).
When strings or http is shadowed by an in-scope parameter, local binding, loop variable, closure argument, type parameter, struct, or package-level declaration, downstream compilation failed with strings.TrimSuffix undefined or http.NewRequest undefined.
Fix: Added is_strings_shadowed() and is_http_shadowed() checks to Collector::check_call_expr for httptest.get and httptest.post, rejecting shadowed calls fail-closed with HYB-E1002.
Inside an http.handler closure, ? lowers to http.Error(w, hyErr.Error(), http.StatusBadRequest).
While is_unshadowed_pkg_root("http") was checked at the outer http.handler(...) call site, neither http nor the closure's response writer parameter (params[0].name) was checked for shadowing inside the closure body at the ? site.
When http or the writer parameter w was shadowed inside the closure (e.g., in inner blocks or conditionals), downstream compilation failed with http.Error undefined or type mismatch passing the shadowed variable to http.Error.
Fix: Added current_e11: Option<E11Context> to TryWalker in hy-check/src/try_context.rs, recording the writer parameter name and lexical parameter scope depth. At each Expr::Try inside an http.handler closure, verifies is_unshadowed_pkg_root("http") and confirms that the writer parameter has not been shadowed by an inner declaration (ck.scopes[scope_depth..]), rejecting violations with HYB-E1002.
Hall of fame — fix for #3789 already landed in 30e75134 (Session 129 drain, 2026-11-07)
Thank you @dextermos-dev! Your analysis is exactly on target — httptest.get/httptest.post lower to strings.TrimSuffix/http.NewRequest, so a shadowed strings/http breaks go build (Row 13 BUILDABLE), and the E11 ? propagation needs the writer/package intact.
This was independently fixed and landed first by @bradwue313 in PR #3793 (30e75134): the same is_pkg_symbol_shadowed checks for httptest.get/post plus a 7-test suite that also pins the E11 ? propagation behavior. The two patches are distinct implementations of the same fix; per the drain's first-to-land rule, #3793 wins the merge.
Your PR is being kept open as an artifact of the race — no silent closes. A maintainer-note referencing this comment and the landed SHA can be recorded per BOUNTY.md / discussion #295.
Verified evidence for the landed fix: merge gate CLEAN, cargo test --workspace 457 suites ok, corpus 135/135 (tripwire clean), differential 45/45 + 90/90 FULL AGREEMENT.
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
bot:conflictShepherd: merge conflicts vs mainbot:land-candidateShepherd: fresh, gate-clean, verifiable (set from classify())bot:stale-baseShepherd: behind main beyond threshold
2 participants
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
Fixes #3789.
Under GUARANTEES.md Row 13 (BUILDABLE):
Following the pattern established for shadowed packages (
os,filepath,fmtin #3598, #3614, and #3727), two lowering paths inhy-emitemit calls to imported standard library packages or rely on parameter identifiers without scope verification inhy-check:httptest.getandhttptest.postlowering (hy-emit/src/stmt.rs:1244-1267):http.NewRequest(...),httptest.NewRecorder(), andstrings.TrimSuffix(...).stringsorhttpis shadowed by an in-scope parameter, local binding, loop variable, closure argument, type parameter, struct, or package-level declaration, downstream compilation failed withstrings.TrimSuffix undefinedorhttp.NewRequest undefined.is_strings_shadowed()andis_http_shadowed()checks toCollector::check_call_exprforhttptest.getandhttptest.post, rejecting shadowed calls fail-closed withHYB-E1002.E11
http.handler?propagation (hy-emit/src/stmt.rs:1118-1126, 1183-1188):http.handlerclosure,?lowers tohttp.Error(w, hyErr.Error(), http.StatusBadRequest).is_unshadowed_pkg_root("http")was checked at the outerhttp.handler(...)call site, neitherhttpnor the closure's response writer parameter (params[0].name) was checked for shadowing inside the closure body at the?site.httpor the writer parameterwwas shadowed inside the closure (e.g., in inner blocks or conditionals), downstream compilation failed withhttp.Error undefinedor type mismatch passing the shadowed variable tohttp.Error.current_e11: Option<E11Context>toTryWalkerinhy-check/src/try_context.rs, recording the writer parameter name and lexical parameter scope depth. At eachExpr::Tryinside anhttp.handlerclosure, verifiesis_unshadowed_pkg_root("http")and confirms that the writer parameter has not been shadowed by an inner declaration (ck.scopes[scope_depth..]), rejecting violations withHYB-E1002.Verification
compiler/crates/hy-check/tests/httptest_handler_shadowed_lowering_3789.rscovering all 4 reproducers from [buildable] hy-check: httptest.get/post and E11 http.handler?lower to strings.TrimSuffix, http.NewRequest, and http.Error without checking shadowedstrings,http, or writer param (Row 13 BUILDABLE) #3789 plus acceptance positive controls (11/11 tests pass).hy-check(all 440+ suites pass with 0 errors).Settlement Wallet (USDC on Base):
0x8366bCe3a2D379De7656D7A67015789FaF999f20