Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sol-macro): bug fixes #372

Merged
merged 2 commits into from
Oct 15, 2023
Merged

fix(sol-macro): bug fixes #372

merged 2 commits into from
Oct 15, 2023

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Oct 15, 2023

Motivation

Fixes #360
Fixes #361
Fixes #371

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@@ -314,7 +314,7 @@ impl<'a> CallLikeExpander<'a> {
.map(Self::#variants)
})*
s => ::core::result::Result::Err(::alloy_sol_types::Error::unknown_selector(
Self::NAME,
<Self as ::alloy_sol_types::SolInterface>::NAME,
Copy link
Member Author

@DaniPopes DaniPopes Oct 15, 2023

Choose a reason for hiding this comment

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

Part of issue #361
expected reference &'static str found enum constructor
this triggered because Self::NAME resolved first as the variant vs the trait constant

Comment on lines -30 to +31
const RESOLVE_LIMIT: usize = 8;
const RESOLVE_LIMIT: usize = 32;
Copy link
Member Author

Choose a reason for hiding this comment

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

pub fn expand(ast: File) -> Result<TokenStream> {
ExpCtxt::new(&ast).expand()
}

/// The expansion context.
struct ExpCtxt<'ast> {
all_items: Vec<&'ast Item>,
custom_types: HashMap<SolIdent, Type>,
custom_types: IndexMap<SolIdent, Type>,
Copy link
Member Author

Choose a reason for hiding this comment

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

IndexMap lets us have deterministic iteration and thus output (errors etc).

Comment on lines +613 to +614
.enumerate()
.filter(|(_, p)| !p.is_indexed())
Copy link
Member Author

@DaniPopes DaniPopes Oct 15, 2023

Choose a reason for hiding this comment

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

#361 title error - enumerate before filter

Comment on lines +402 to +405
// trailing comma for single-element tuples
if components.len() == 1 {
out.push(',');
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@DaniPopes DaniPopes merged commit 0706604 into main Oct 15, 2023
20 checks passed
@DaniPopes DaniPopes deleted the dani/sol-fixes branch October 15, 2023 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant