Open gafter opened 1 year ago
I think i agree with @nystrom. Or at least, you could consider asserting that there's only a single struct declaration in there. It seems it would a bit strange to encounter something like:
@auto_hash_equals begin
struct Foo end
struct Bar end
end
As a reader, i would probably incorrectly assume the macro is applying to all the structs, not just the first. No reason to keep this potential misunderstanding, i think.
The problem is that the block might be the result of applying a macro to the struct, and there might be a LineNumberNode
in there when it is the result of applying the other macro. This is a scenario I'm trying to enable. So I think I do need to skip LineNumberNode
s. However, your suggestion to assert a single struct or apply to every struct in the block if that situation arises - makes sense.
@NHDaly Asserting that there is only one struct would break this package's ability to interoperate with another hypothetical macro that produces a utility type during its expansion (inside begin
... end
, which you get implicitly from quote
). Is that what we intend?
hrmm yeah those are good points! Sorry for my long delay. 🤔 Yeah i don't have a great suggestion here then...
It's worth noting that i think macros run outside-in, so you should be able to see what the user wrote before any macros are expanded inside the usage?
in https://github.com/gafter/AutoHashEqualsCached.jl/pull/1#discussion_r1150925015 @nystrom wrote: