Repository navigation
fix(hy-check): reject declarations named none, the option constructor (HYB-E1002, Row 13) - #3798
Merged
limitlessprojects merged 1 commit intoNov 7, 2026
Conversation
cursor
Bot
force-pushed
the
fix-none-predeclared-declarations
branch
from
November 6, 2026 12:12
6d478f7 to
c43d3db
Compare
cursor
Bot
force-pushed
the
fix-none-predeclared-declarations
branch
5 times, most recently
from
November 6, 2026 20:39
f8f854b to
ce6d0e2
Compare
…YB-E1002) hy-emit treats every bare Ident `none` as the option constructor, so a declaration named `none` (local, param, fn, field, …) passed hyb check with 0 diagnostics and then failed hyb build with `not yet supported: none outside a return` (GUARANTEES Row 13). Reject each declaration site the same way as `default` (limitlessprojects#3677). `return none` and match arms `none:` / `none =>` are not declarations and stay accepted. Regression tests in hy-check/tests/go_keyword_none_names.rs.
cursor
Bot
force-pushed
the
fix-none-predeclared-declarations
branch
from
November 6, 2026 21:30
ce6d0e2 to
32cd931
Compare
limitlessprojects
merged commit Nov 7, 2026
7cdea0a
into
limitlessprojects:main
2 of 3 checks passed
Owner
Landed in
|
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.
What happens (main @ 3d029ca)
SPEC LX3 lists
noneas a predeclared identifier. hy-emit, however, treats every bare Identnoneas the option constructor (return noneagainst a declaredoption[T], ornot yet supported: none outside a returnanywhere else). A declaration that steals the name therefore passes check and fails build:The same accept-then-fail shape hits locals (
:=/var), params, named results, receivers, type params,fn/ method names, struct fields, aliases, consts, for-in / range variables, select-receive names, match bindings, and closure params. Each is an accepted program that does not build — GUARANTEES Row 13.Fix
Extend the existing
go_keyword_namespass (thedefaultwalk from #3677) so a declaration namednoneis HYB-E1002, e.g.local named `none` — `none` is Hybrid's option constructor, so hy-emit cannot treat the name as an ordinary binding and `hyb build` fails.return noneand match armsnone:/none =>are not declarations, so they stay accepted. Names that merely contain the word (none_val,is_none) and a shadowedsomestay accepted.Alternative considered: teach hy-emit to honour a shadowed
none(SPEC's "shadowable with a lint"). That needs full scope tracking at every Ident site and interacts with #1657 (lower unboundnonein value positions to the option zero). Rejecting at check fails closed, matches howdefaultwas handled, and can be relaxed later if emit learns to shadow.Not a duplicate of #1657 / #1298 (emit lowering of unbound
noneas option zero) — those implement the constructor; this rejects declarations that steal the name.Tests
New
compiler/crates/hy-check/tests/go_keyword_none_names.rs, 2 tests:every_declaration_site_named_none_is_rejected— 17 programs, one per site (mirrors thedefaultmatrix)option_none_surface_and_similar_names_stay_accepted—return none, match arms,none_val/is_none,.or/.is_none(), shadowedsomeExisting
go_keyword_default_names.rssuite still green.Verification (local; rustc 1.85.1,
HYB_PINNED_RUST=1.85.1 HYB_ALLOW_TOOLCHAIN_DRIFT=1)cargo test -p hy-check --test go_keyword_none_names --test go_keyword_default_names: 2 + 2 passed, 0 failed.Diff: 2 files, +114 / −0.
Payout Wallet (USDC on Base / EVM):
0x26AB46a0309C3ab8F2f59754B3066e77E8154A34