Skip to content

fix(hy-check): reject shadowed strings/http in httptest.get/post and E11 ? propagation (fixes #3789) - #3793

Merged
limitlessprojects merged 3 commits into
limitlessprojects:mainfrom
bradwue313:fix/httptest-e11-shadowed-lowering-3789
Nov 6, 2026
Merged

limitlessprojects merged 3 commits into
limitlessprojects:mainfrom
bradwue313:fix/httptest-e11-shadowed-lowering-3789

Conversation

@bradwue313

Copy link
Copy Markdown
Contributor

Fixes #3789

Summary

Under GUARANTEES.md Row 13 (BUILDABLE), any program accepted by hyb check must emit Go code that compiles under go build.

Following #3598 / #3727:

  1. httptest.get and httptest.post lowering (compiler/crates/hy-emit/src/stmt.rs:1244-1267):
    code, body := httptest.get(mux, path)? and httptest.post(mux, path)? lower to http.NewRequest(...) and strings.TrimSuffix(...). When strings or http is shadowed by an in-scope parameter, local binding, type parameter, or package-level declaration, emitted Go fails downstream go build (strings.TrimSuffix undefined / http.NewRequest undefined).
  2. E11 http.handler ? propagation (compiler/crates/hy-emit/src/stmt.rs:1118-1126, 1183-1188):
    Inside an http.handler closure, ? lowers to http.Error(<w>, hyErr.Error(), http.StatusBadRequest). When http or the response writer parameter <w> is shadowed inside the closure body at the ? site, emitted Go fails downstream go build.

Fix

  • In compiler/crates/hy-check/src/buildable.rs: check self.is_pkg_symbol_shadowed("strings") and self.is_pkg_symbol_shadowed("http") on httptest.get and httptest.post calls, emitting HYB-E1002.
  • In compiler/crates/hy-check/src/try_context.rs: track the active E11 handler writer parameter (e11_writer: Option<(String, usize)>) and emit HYB-E1002 when ? is evaluated inside an E11 handler closure while http or the writer parameter is shadowed in an enclosing scope.
  • Added hermetic regression test suite compiler/crates/hy-check/tests/shadowed_httptest_and_e11_handler_3789.rs (5 negative reject controls + positive accept control).

Payout Wallet (USDC on Base): 0x38e0f40371be8b30f0909f890a1f701a25cd30cd

@bradwue313
bradwue313 force-pushed the fix/httptest-e11-shadowed-lowering-3789 branch from 1f38572 to 58ae606 Compare November 6, 2026 09:14
@github-actions github-actions Bot added the bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify()) label Nov 6, 2026
@limitlessprojects
limitlessprojects merged commit 30e7513 into limitlessprojects:main Nov 6, 2026
3 checks passed
@limitlessprojects

Copy link
Copy Markdown
Owner

Landed in 30e75134 — merged into main (Session 129 drain, 2026-11-07)

Thank you @bradwue313 — this is landed with a merge credit commit CREDIT: @bradwue313 (fixes #3789).

What landed (PR head 615d459d):

In-merge fixture fixup (credited in the merge commit): the patch had replaced 10 UTF-8 arrows in unrelated doc comments (8 × →, 2 × ↔ → literal ?) and appended a stray EOF blank line; all restored byte-identical to prior main inside this merge. Net change: +25 check lines + the 85-line test file.

Verification evidence (full battery on the trial-merge worktree vs main @ 973453c5):

  • merge gate: CLEAN
  • cargo test --workspace: 457 suites ok, 0 failed
  • corpus harness: 135/135, tripwire not fired
  • differential loop: 45/45 accept + 90/90 reject — FULL AGREEMENT
  • post-merge net diff vs prior main verified to contain only the check block and the test file; origin/main == local HEAD after push (30e75134).

Bounty rail: per BOUNTY.md / discussion #295 — eligibility for #3789 recorded with this landing.

limitlessprojects pushed a commit that referenced this pull request Nov 6, 2026
The #3793 merge commit (30e7513) carried the PR's incidental encoding
damage: 10 doc-comment arrows (8 x U+2192, 2 x U+2194) had been replaced
with literal ? and a stray blank line was appended at EOF. The intended
in-merge restoration was written to the worktree but not staged before
the merge committed, so the damage shipped.

This commit restores all 10 comment lines byte-identical to their
pre-merge state and drops the EOF blank line. Code semantics unchanged
(comments only); the #3793 check block and test suite are untouched.

CREDIT: @bradwue313 (the #3793 fix itself; this is a drain-side fixup)
@limitlessprojects

Copy link
Copy Markdown
Owner

Correction to the landing note above (Session 129 drain, 2026-11-07):

The merge commit 30e75134 shipped the PR's incidental encoding damage (10 doc-comment arrows → literal ?, one stray EOF blank line): the restoration was prepared during the merge but was not staged before the merge committed, so the damage landed. It is now restored byte-identical to pre-merge state in follow-up commit a516dd26 (fixup(30e75134): restore UTF-8 arrows in buildable.rs doc comments). Code semantics unchanged — comments only; your check block and the 7-test suite are untouched in both commits.

Evidence claims in the landing note (merge gate CLEAN, 457 suites, corpus 135/135 tripwire clean, differential 45/45 + 90/90 FULL AGREEMENT) remain accurate; the net-diff note now reads: merge commit carried your fix + the comment noise, a516dd26 removed the noise. origin/main == a516dd26 at time of writing.

limitlessprojects pushed a commit that referenced this pull request Nov 7, 2026
…ing calls (E3/E4, fixes #3793-family operand half) (RPMFAN)

try_context.rs: new check_try_operand closes the E3 "calls only" / E4 operand half — `?` postfix on
a non-call (`1?`, `x.f?`, `none?`), a call whose known results do not end in error, and calls
returning option[T] (is_option_type via resolve_type_alias) all reject HYB-E2011 at the operand
span; unresolved/foreign/locally-shadowed callees stay fail-open (owned by emit/other passes).
fn_decl_type_param_names helper extracted (same Decl::Fn collection reused by fnlit walk). New
suite pins rejects + positive controls.

Verification (trial-merge worktree vs main @ d96b7a9): merge-gate CLEAN; cargo test --workspace
459 suites ok; corpus 135/135 tripwire not fired; differential 45/45 accept + 90/90 reject FULL
AGREEMENT.

CREDIT: @RPMFAN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify())

Projects

None yet

2 participants