I would like to use two macros to add extra functions to one struct, namely
@with_kw (from Parameters.jl )
and
@auto_hash_equals (from AutoHashEquals.jl ).
using Parameters, AutoHashEqual
@with_kw @auto_hash_equals struct S1
x::Float64 = 1.0
end
@auto_hash_equals @with_kw struct S2
x::Float64 = 1.0
end
Is there a way to apply both macros at the same time? Thanks!
I get the following errors.
For S1
:
ERROR: LoadError: Only works on type-defs or named tuples.
Make sure to have a space after `@with_kw`, e.g. `@with_kw (a=1,)
Also, make sure to use a trailing comma for single-field NamedTuples.
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] with_kw(::Expr, ::Module, ::Bool) at /home/plunder/.juliapro/JuliaPro_v1.0.5-2/packages/Parameters/l76EM/src/Parameters.jl:307
[3] @with_kw(::LineNumberNode, ::Module, ::Any) at /home/plunder/.juliapro/JuliaPro_v1.0.5-2/packages/Parameters/l76EM/src/Parameters.jl:631
in expression starting at REPL[11]:1
For S2
:
ERROR: LoadError: AssertionError: typ.head == :type || typ.head == :struct
Stacktrace:
[1] @auto_hash_equals(::LineNumberNode, ::Module, ::Any) at /home/plunder/.juliapro/JuliaPro_v1.0.5-2/packages/AutoHashEquals/tDuUH/src/AutoHashEquals.jl:67
in expression starting at REPL[9]:1