Skip to content

Conversation

phrwlk
Copy link
Contributor

@phrwlk phrwlk commented Oct 6, 2025

The dynamic test linking preprocessor failed to preserve the contract type for try-constructor statements. For code like try new C(...) returns (C c) { ... }, the transformation produced vm.deployCode(...) without wrapping, leaving the expression typed as address. This mismatched the expected type C and could fail compilation when a returns (C) clause was present.

This change unifies handling for both try and non-try constructor creations by always wrapping the transformed expression as C(payable(vm.deployCode({...}))), ensuring the resulting type remains the contract type. Added a CLI test that asserts try new C(...) returns (C c) compiles after preprocessing.

@grandizzy
Copy link
Collaborator

thank you! that's a valid bug but needs a little bit more complex fix, will include in #12050 with the test you added

@grandizzy grandizzy closed this Oct 10, 2025
@github-project-automation github-project-automation bot moved this to Done in Foundry Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants