Add diagnostics system and improve type-based mapping detection #57
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
This PR introduces a comprehensive diagnostics/warning system for the transpiler and improves type information usage throughout code generation. The changes help developers understand simulation fidelity gaps by reporting unsupported Solidity constructs that were skipped or degraded during transpilation.
Key Changes
Diagnostics System (New)
transpiler/codegen/diagnostics.pywithTranspilerDiagnostics,Diagnostic, andDiagnosticSeverityclassesCodeGenerationContextandSol2TstranspilerType-Based Mapping Detection
statement.py: Replaced name-based heuristics with type registry lookups for mapping detectionvar_typesandcurrent_state_varsto determine if a variable is a mappingexpression.py: Improved struct field mapping detection usingknown_struct_fieldsregistryInterface Type Handling
type_converter.py: Interface types now generate as their actual names instead of collapsing toanycontracts_referencedfor import generationtype_system/registry.py: Addedinterface_methodstracking to record method signaturesABI Type Inference Refactoring
expression.py: Delegated ABI type conversion to newAbiTypeInfererclassYul Transpiler Enhancements
transpiler/codegen/yul.pywith improved parsing and code generationTesting
Notable Implementation Details
CodeGenerationContext.diagnosticsproperty creates aTranspilerDiagnosticsinstance on first accessSol2Ts._emit_ast_diagnostics()scans the AST to detect and report unsupported constructs before code generationvar_typesandknown_struct_fieldsfor accurate type informationBackward Compatibility
All changes are additive or improve existing behavior without breaking changes. The diagnostics system is optional and non-blocking.
https://claude.ai/code/session_01GtZHJWCpU7GiocausVWvax