Repository navigation
hy-check(const_init): reject type-parameter shadows on const conversions, ascriptions, and file constants (fixes #3851) - #3867
Merged
limitlessprojects merged 1 commit intoNov 7, 2026
Conversation
dextermos-dev
force-pushed
the
fix-const-init-type-param-shadows-3851
branch
from
November 6, 2026 13:02
0209fd1 to
12b26ce
Compare
dextermos-dev
force-pushed
the
fix-const-init-type-param-shadows-3851
branch
from
November 6, 2026 14:24
12b26ce to
bab307e
Compare
…ons, ascriptions, and file constants (fixes limitlessprojects#3851)
dextermos-dev
force-pushed
the
fix-const-init-type-param-shadows-3851
branch
from
November 7, 2026 18:03
bab307e to
5e73f6b
Compare
Contributor
Owner
Landed —
|
| Gate | Result |
|---|---|
Trial merge vs current main |
clean (2 files: const_init.rs + new suite) |
| New suite standalone | issue_3851_const_init_type_param_shadow — 2/2 pass |
cargo test --workspace |
exit 0, 486 suites, 3102 passed, 0 failed |
| Integration files | 476 → 477 on disk (ls verified, log 1:1) |
| Corpus harness | 135/135 verdict agreement, tripwire not fired |
| Differential loop FULL | 45/45 accept-side, 90/90 reject-side — FULL AGREEMENT |
Review notes
- The threading of
FnStatethrough all six const-init verdict sites is exactly the right shape: conversion callee (s.type_params.contains(ty_name)), conversion target + alias-resolved target, string conversion target,Expr::Ident,is_const_allowed_ty(entry + resolved + Primitive/Str fast path). Everything fails closed toward not-constant, which is the correct direction for BUILDABLE. - The duplicated type-param check in the
Primitive | Strfast path is technically redundant with the entry check but harmless (defense in depth afterresolve_type_alias). - Fixtures follow the lowercase type-param recipe (LX2 identifier case) — parses clean first try.
- Both directions covered: shadowed →
HYB-E6003(reproducer +len(s)variant), unshadowed control stays silent.
Bounty
Per BOUNTY.md / discussion #295: this lands against issue #3851 — bounty claim recorded for @dextermos-dev on that issue's rail.
This was referenced Nov 7, 2026
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
Fixes #3851.
Under GUARANTEES.md Row 13 (BUILDABLE):
In Go, generic type parameters cannot be evaluated as constants, converted as constant targets, or ascribed to constants. In
compiler/crates/hy-check/src/const_init.rs:expr_is_constant_innerforExpr::Callandis_const_conversion_targetverified local bindings inst.env_lookupand file declarations, but did not checkst.type_params.type my_int = int; fn f[my_int]() { const c = my_int(1) }), it accepted the non-constant conversion.s.type_params.contains(ty_name)checks toExpr::Callandis_const_conversion_target.is_const_allowed_tydid not receivestand checked only global declarations, failing to detect whenconst c my_int = 1had its ascriptionmy_intshadowed by a function type parametermy_int.st: Option<&FnState>throughis_const_allowed_ty, rejecting any type whose root or resolved alias matches an in-scope type parameter (st.type_params.contains(name)).ident_is_constant,Expr::Identfell back to file-levelfile_const_declwhen an identifier was not inst.env_lookup, ignoring function type parameters.const k = 42; fn f[k]() { const e = k + 1 }andconst s = "abc"; fn f[s]() { const n = len(s) }, the checker incorrectly resolvedk/sto the file constant.st.type_params.contains(name)checks toident_is_constantandis_const_string_expr, ensuring function-scoped type parameters correctly shadow file-level constants fail-closed withHYB-E6003.Verification
compiler/crates/hy-check/tests/issue_3851_const_init_type_param_shadow.rscovering:my_int(1)-> rejectsHYB-E6003.const d my_int = 1-> rejectsHYB-E6003.k + 1-> rejectsHYB-E6003.len(s)-> rejectsHYB-E6003.cargo test -p hy-check --lib(183/183 unittests pass).Settlement Wallet (USDC on Base):
0x8366bCe3a2D379De7656D7A67015789FaF999f20