Skip to content

fix: resolve struct/enum types from imported scopes during parsing#2972

Open
ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
ep0chzer0:fix/imported-struct-type-resolution
Open

fix: resolve struct/enum types from imported scopes during parsing#2972
ep0chzer0 wants to merge 1 commit intocrytic:masterfrom
ep0chzer0:fix/imported-struct-type-resolution

Conversation

@ep0chzer0
Copy link
Contributor

Summary

  • Fixes Structs.ShiftChanges #2954 - ParsingError: Type not found struct Structs.ShiftChanges when a contract uses struct types from an imported library
  • Root cause: parse_type() built all_structures/all_enums only from scope.contracts.values() (current file), missing types from scope.accessible_scopes (imported files)
  • Extended type search in both the top-level context path and the ContractSolc/FunctionSolc path to also include structures, enums, and contracts from accessible (imported) scopes

Test plan

  • Added regression test test_imported_struct_from_library with a library defining structs imported by a consumer contract
  • Existing tests pass (no regressions in type resolution)
  • Verified with ruff check and ruff format

@ep0chzer0 ep0chzer0 requested a review from smonicas as a code owner February 23, 2026 22:10
When parsing types in ContractSolc/FunctionSolc and top-level contexts,
_find_from_type_name only searched structures and enums from the current
file scope's contracts. This caused a ParsingError ("Type not found")
when a contract referenced a struct defined in an imported library
(e.g., `Structs.ShiftChanges`).

Extended the type search to also include structures, enums, and
contracts from `scope.accessible_scopes`, which contains the file
scopes of all imported files.

Fixes crytic#2954
@ep0chzer0 ep0chzer0 force-pushed the fix/imported-struct-type-resolution branch from 3e56d21 to f83ac2b Compare February 26, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Structs.ShiftChanges

1 participant