refactor(ir): centralize storage-dtype composition, de-panic array indices - #17
Open
Boreas618 wants to merge 2 commits into
Open
refactor(ir): centralize storage-dtype composition, de-panic array indices#17Boreas618 wants to merge 2 commits into
Boreas618 wants to merge 2 commits into
Conversation
…dices
compose_var_decl_dtype/compose_var_def_dtype are the documented canonical
helpers for combining a base Dtype with an AST declaration shape, but
handle_struct_def and type_infer each kept their own inline copies of the
same scalar/array composition. Delegate to the helpers wherever the input
shapes and semantics are genuinely identical:
- module_gen::handle_struct_def now calls compose_var_decl_dtype for
struct member storage types;
- type_infer::process_var_def delegates its array arm to
compose_var_def_dtype;
- type_infer::process_var_decl delegates every resolved case to
compose_var_decl_dtype. The untyped-scalar arm stays inline (with a
comment recording the divergence) because it must remain Pending rather
than defaulting to i32.
array_index_operand lowered source-derived usize indices with
i32::try_from(..).expect(..), panicking on user input. Add
Error::ArrayIndexTooLarge { index } and propagate it from the three call
sites instead.
Also add the missing //! module docs to ir/error.rs, ir/types.rs and
ir/gen/static_eval.rs, matching the documented siblings.
- removed 16 divider banner groups (4 function_gen, 12 type_infer)
- removed 11 obvious narrations/restatements (emit-store, lower-body,
eval-condition, jump-past-else, emit-loop-test, 2 short-circuit
duplicates, finalise-block, alloca-hoist restatement, insert-hoisted)
- removed 1 duplicated impl-block doc (static_eval restated module doc)
- rewrote 4 stale/contradictory comments: generate() #Errors claimed an
impossible UnsupportedReturnType, 'two-phase' impl doc vs 3-pass body,
local_base_dtype unreachable fallback example, post-hoist invariant
(referenced empty blocks panic, edges are never dropped)
- rewrote 4 first-person formulations to declarative facts
- trimmed 1 unsupported claim ('no program will ever approach it')
- de-linked 5 unresolved intra-doc links to private/out-of-scope items
(doc warnings 27 -> 23)
- no TODO/FIXME/HACK tags and no commented-out code found in scope
Boreas618
force-pushed
the
refactor/ir-dtype-helpers
branch
from
August 1, 2026 10:59
b086b95 to
4826153
Compare
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.
IR-layer unification from the cross-layer audit:
compose_var_decl_dtype/compose_var_def_dtype(documented as the single home for storage-type computation) are now actually used byhandle_struct_defandtype_infer, eliminating the inline duplicated matches; the one legitimately divergent site intype_inferis left in place with a comment explaining why.array_index_operand(i32::try_from(index).expect(...)on a source-derived index) is now a properError::ArrayIndexTooLargevariant.//!module docs added toir/error.rs,ir/types.rs,ir/gen/static_eval.rs.Verified:
cargo test30/30 green.