File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -123,12 +123,17 @@ function parse_obj_lenses(ex)
123123 lens = :($ IndexLens ($ index))
124124 end
125125 elseif @capture (ex, front_. property_)
126- property isa Union{Symbol,String} || throw (ArgumentError (
127- string (" Error while parsing :($ex ). Second argument to `getproperty` can only be" ,
128- " a `Symbol` or `String` literal, received `$property ` instead." )
129- ))
130126 obj, frontlens = parse_obj_lenses (front)
131- lens = :($ PropertyLens {$(QuoteNode(property))} ())
127+ if property isa Union{Symbol,String}
128+ lens = :($ PropertyLens {$(QuoteNode(property))} ())
129+ elseif is_interpolation (property)
130+ lens = :($ PropertyLens {$(esc(property.args[1]))} ())
131+ else
132+ throw (ArgumentError (
133+ string (" Error while parsing :($ex ). Second argument to `getproperty` can only be" ,
134+ " a `Symbol` or `String` literal, received `$property ` instead." )
135+ ))
136+ end
132137 elseif @capture (ex, f_ (front_))
133138 obj, frontlens = parse_obj_lenses (front)
134139 lens = :($ FunctionLens ($ (esc (f))))
Original file line number Diff line number Diff line change 509509 @test @lens ($ lbc)== lbc
510510 @test @lens (_. a ∘ $ lbc) == @lens (_. a) ∘ lbc
511511 @test @lens (_. a ∘ $ lbc ∘ _[1 ] ∘ $ lbc) == @lens (_. a) ∘ lbc ∘ @lens (_[1 ]) ∘ lbc
512+
513+ name = :a
514+ @test @lens (_.$ name) == @lens (_. a)
512515end
513516
514517end
You can’t perform that action at this time.
0 commit comments