You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some macros inject code that calls trait functions, which issues a warning unless the user has imported the trait. This should not be the case, using a macro should require nothing other than importing it. Macros can't inject imports since those have already been processed at macro resolution, so we need an alternative strategy.
What we discussed with Jake from Noir is to have the resolution happen inside the macro by injecting resolved functions instead of plain quoted tokens. This makes the macros a bit harder to parse, but much more robust.
Instead of e.g.
quote {
letnote_type_id = $typ.get_note_type_id(); // Requires the NoteInterface trait to be imported
}
we'd do
usecrate::note::note_interface::NoteInterface;
letget_note_type_id = $typ.as_trait_impl(NoteInterface).methods.get_note_type_id; // This is not the actual Noir APIquote {
letnote_type_id = $get_note_type_id();
Some work remains on Noir to achieve this (I think noir-lang/noir#7315 and/or noir-lang/noir#7314) - we need to coordinate with them to ensure this is possible.
Activity
asterite commentedon Feb 13, 2025
In Noir master this should now be possible:
benesjan commentedon Feb 13, 2025
Thanks @asterite . Will give it a try once we get a Noir sync.
TomAFrench commentedon Feb 14, 2025
This is now synced.