Skip to content

Bug fixes + refactorings + tests#180

Open
0xGeorgii wants to merge 10 commits intomainfrom
bug-fixes
Open

Bug fixes + refactorings + tests#180
0xGeorgii wants to merge 10 commits intomainfrom
bug-fixes

Conversation

@0xGeorgii
Copy link
Contributor

No description provided.

… struct nondeterminism in code generation

- Introduced tests for analysis rule A023 (UzumakiInReassignment) to ensure that reassignment of variables to the Uzumaki type is correctly rejected.
- Added tests for analysis rule A024 (ExternFunctionCall) to validate that calls to external functions are properly flagged as errors.
- Created new test data for struct nondeterminism in the code generation process, including various struct definitions and their corresponding functions.
- Updated the WASM output to include the new struct nondeterminism tests.
@0xGeorgii 0xGeorgii self-assigned this Mar 23, 2026
@0xGeorgii 0xGeorgii added tests Unit, fuzzing, performance, etc. refactoring Project supplements static analysis Static code analysis labels Mar 23, 2026
@0xGeorgii 0xGeorgii requested a review from Copilot March 23, 2026 07:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands the compiler pipeline by migrating a set of validation checks from the type checker into the analysis phase, adds WASM codegen support for struct-typed uzumaki (@) by lowering it into per-field nondeterministic stores, and updates test fixtures/utilities accordingly.

Changes:

  • Add analysis rules A006–A024 (and extensive integration tests) to enforce constraints previously implemented in the type checker.
  • Extend WASM codegen to support struct-typed uzumaki in variable definitions by emitting field-wise uzumaki + stores.
  • Tighten/adjust type checker behavior (e.g., case-sensitive builtins, uninitialized vars rejected, duplicate fields/variants, recursive structs, division-by-zero literals) and update tests/fixtures and test helpers (including “skip analysis” codegen helpers).

Reviewed changes

Copilot reviewed 47 out of 48 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/test_data/codegen/wasm/base/struct_nondet/struct_nondet.wasm New golden WASM output for struct nondet codegen fixture.
tests/test_data/codegen/wasm/base/struct_nondet/struct_nondet.inf New source fixture exercising struct-typed uzumaki inside nondet blocks.
tests/src/utils.rs Add helpers to run codegen without analysis and variants with explicit mode/target.
tests/src/type_checker/type_info_tests.rs Update tests to enforce case-sensitive parsing and add "String" builtin coverage.
tests/src/type_checker/type_checker.rs Update tests for migrated checks; add tests for recursive structs, div-by-zero, duplicates, invalid assignment target, const mismatch, etc.
tests/src/type_checker/struct_tests.rs Update tests for migrated compound-literal / compound-call restrictions (now analysis-owned).
tests/src/type_checker/features.rs Update samples to avoid now-invalid uninitialized declarations.
tests/src/type_checker/coverage.rs Flip expectations for uninitialized vars; add case-sensitivity coverage.
tests/src/type_checker/array_tests.rs Update array tests to avoid uninitialized declarations and reflect migrated range/index rules.
tests/src/codegen/wasm/validation.rs Switch selected codegen tests to use no-analysis helpers where analysis would reject patterns.
tests/src/codegen/wasm/negative.rs Rework negative tests: type-check failures for uninitialized vars; add analysis rejection for extern calls; adjust uzumaki compound tests.
tests/src/codegen/wasm/base.rs Run fixture-based codegen via no-analysis helper; add struct uzumaki coverage + regeneration hook.
tests/src/ast/mod.rs Export helpers module from the test AST module tree.
tests/src/analysis/rules_a024.rs Add integration tests for analysis rule A024 (extern function calls).
tests/src/analysis/rules_a023.rs Add integration tests for analysis rule A023 (uzumaki in reassignment).
tests/src/analysis/rules_a012_a022.rs Add integration tests for migrated analysis rules A012–A022 plus condition-expression traversal cases.
tests/src/analysis/rules_a006_a011.rs Add integration tests for analysis rules A006–A011 (nondet placement, missing return, empty defs, etc.).
tests/src/analysis/mod.rs Register new analysis-rule integration test modules.
core/wasm-codegen/src/compiler.rs Implement struct-typed uzumaki lowering (field-wise stores) and hook it into uzumaki codegen.
core/type-checker/src/type_info.rs Make number/builtin parsing case-sensitive; add "String" as a builtin alias for string type.
core/type-checker/src/type_checker.rs Remove migrated checks; add new checks (duplicate fields/variants, recursive structs, invalid assignment targets, required init, array literal size match, div-by-zero literal, const typing tweaks).
core/type-checker/src/symbol_table.rs Make lookup_type case-sensitive (remove lowercase fallback).
core/type-checker/src/errors.rs Remove migrated error variants; add new error variants and display tests for new type-checker errors.
core/ast/src/builder.rs Adjust function-argument parsing to handle grammar nodes with/without argument_list.
core/analysis/src/rules/uzumaki_outside_nondet_block.rs New A006 rule implementation (currently stmt-pattern based).
core/analysis/src/rules/uzumaki_in_reassignment.rs New A023 rule implementation.
core/analysis/src/rules/struct_literal_as_argument.rs New A013 rule implementation.
core/analysis/src/rules/standalone_uzumaki.rs New A008 rule implementation.
core/analysis/src/rules/mod.rs Register new analysis rules and include them in all_rules().
core/analysis/src/rules/missing_return.rs New A007 rule implementation (whole-body return-path analysis).
core/analysis/src/rules/method_never_accesses_self.rs New A010 rule implementation (migrated from type checker).
core/analysis/src/rules/method_call_chain_compound.rs New A018 rule implementation.
core/analysis/src/rules/literal_out_of_range.rs New A022 rule implementation (typed literal bounds checks).
core/analysis/src/rules/extern_function_call.rs New A024 rule implementation (reject extern calls pre-codegen).
core/analysis/src/rules/empty_struct_definition.rs New A011 rule implementation (warning).
core/analysis/src/rules/empty_enum_definition.rs New A009 rule implementation (warning).
core/analysis/src/rules/compound_return_call_position.rs New A016 rule implementation.
core/analysis/src/rules/compound_return_call_assignment.rs New A017 rule implementation.
core/analysis/src/rules/compound_literal_position.rs New A015 rule implementation.
core/analysis/src/rules/array_uzumaki_as_argument.rs New A014 rule implementation.
core/analysis/src/rules/array_literal_as_argument.rs New A012 rule implementation.
core/analysis/src/rules/array_index_64bit.rs New A019 rule implementation.
core/analysis/src/lib.rs Update internal diagnostic/rule-id mapping test vector to include new diagnostics.
core/analysis/src/errors.rs Add new AnalysisDiagnostic variants and wire them into location + rule-id mapping.
apps/infs/tests/fixtures/nondet.inf Update fixture to place uzumaki inside a nondet block rather than direct return.
Cargo.toml Bump tree-sitter-inference version to 0.0.40.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…agnostics

- Introduced new analysis rules for control flow, lint warnings, and codegen restrictions.
- Migrated 13 checks from the type checker to the analysis pass, reducing type checker error variants from 50 to 46.
- Added new `TypeCheckError` variants for improved validation, including checks for duplicate struct fields and recursive struct definitions.
- Implemented detailed diagnostics for uninitialized variables, invalid assignment targets, and division by zero.
- Enhanced struct uzumaki support for non-deterministic initialization of struct fields.
- Updated documentation to reflect changes in error handling and analysis rules.
- Improved test coverage for new analysis rules and fixed existing tests to align with the updated code structure.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 54 out of 55 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 54 out of 55 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +983 to +987
&& let TypeInfoKind::Array(ref elem_type, expected_size) = target_type.kind
{
if elements.len() != expected_size as usize {
self.errors.push(TypeCheckError::ArrayLiteralSizeMismatch {
expected: expected_size,
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this if let chain, matching on target_type.kind moves the kind field out of target_type. Since target_type is subsequently used (e.g., cloned / passed to push_variable_to_scope), this will not compile due to a partial move. Match on a reference instead (e.g., if let TypeInfoKind::Array(elem_type, expected_size) = &target_type.kind) or clone target_type.kind before matching.

Suggested change
&& let TypeInfoKind::Array(ref elem_type, expected_size) = target_type.kind
{
if elements.len() != expected_size as usize {
self.errors.push(TypeCheckError::ArrayLiteralSizeMismatch {
expected: expected_size,
&& let TypeInfoKind::Array(elem_type, expected_size) = &target_type.kind
{
if elements.len() != *expected_size as usize {
self.errors.push(TypeCheckError::ArrayLiteralSizeMismatch {
expected: *expected_size,

Copilot uses AI. Check for mistakes.
- Migrate struct literal argument check (A013) to a combined rule for compound literals (A012).
- Implement new rule A012: Compound literals (array/struct) cannot be passed directly as function arguments.
- Introduce rule A020: Detect unreachable code after `return` or `break` statements.
- Remove deprecated struct literal argument rule file.
- Update tests to reflect changes in rule IDs and expected diagnostics.
- Enhance walker functions to streamline expression handling in statements.
…nitializers

- Removed the `UninitializedVariable` error from the type checker and added a new analysis rule to enforce that all variables must be initialized at declaration.
- Updated documentation and error messages to reflect the new rule.
- Added comprehensive tests for the new rule, including various scenarios for uninitialized variables and ensuring correct error reporting.
- Adjusted existing tests to accommodate the removal of the `UninitializedVariable` error from the type checker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Project supplements static analysis Static code analysis tests Unit, fuzzing, performance, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants