Skip to content

hy-check: reject shadowed strings/http in httptest and shadowed http/writer in http.handler (fixes #3789) - #3794

Open
dextermos-dev wants to merge 2 commits into
limitlessprojects:mainfrom
dextermos-dev:fix-httptest-and-handler-shadowed-lowering-3789
Open

dextermos-dev wants to merge 2 commits into
limitlessprojects:mainfrom
dextermos-dev:fix-httptest-and-handler-shadowed-lowering-3789

Conversation

@dextermos-dev

Copy link
Copy Markdown
Contributor

Summary

Fixes #3789.

Under GUARANTEES.md Row 13 (BUILDABLE):

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:

  1. 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.
  2. E11 http.handler ? propagation (hy-emit/src/stmt.rs:1118-1126, 1183-1188):

    • 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.

Verification


Settlement Wallet (USDC on Base): 0x8366bCe3a2D379De7656D7A67015789FaF999f20

@dextermos-dev
dextermos-dev force-pushed the fix-httptest-and-handler-shadowed-lowering-3789 branch from 81a9ee0 to 5cecf44 Compare November 6, 2026 14:23
@github-actions github-actions Bot added the bot:stale-base Shepherd: behind main beyond threshold label Nov 6, 2026
@limitlessprojects

Copy link
Copy Markdown
Owner

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.

@github-actions github-actions Bot added the bot:conflict Shepherd: merge conflicts vs main label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:conflict Shepherd: merge conflicts vs main bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify()) bot:stale-base Shepherd: behind main beyond threshold

Projects

None yet

2 participants