File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,10 @@ function parse_obj_optics(ex)
248248 obj, frontoptic = parse_obj_optics (args[2 ])
249249 optic = :(Base. Fix1 ($ f, $ (esc (args[1 ]))))
250250 end
251+ elseif @capture (ex, s_Symbol)
252+ # the symbol can be wrapped in quote ... end, need to unwrap for reliable handling downstream
253+ obj = esc (s)
254+ return obj, ()
251255 else
252256 obj = esc (ex)
253257 return obj, ()
Original file line number Diff line number Diff line change @@ -602,6 +602,7 @@ struct MyStruct
602602end
603603" Documentation for my_x"
604604@accessor my_x (v) = v. x
605+ @accessor my_identity (v) = v
605606@accessor Base.:(+ )(s:: MyStruct ) = 5 - s. x. a
606607@accessor Base. Int (s:: MyStruct ) = s. x[1 ]
607608@accessor Base. Float64 (s:: MyStruct ) = s. x[2 ]
@@ -617,6 +618,7 @@ import REPL
617618 @test (@set my_x (s) = 456 ) === MyStruct (456 )
618619 @test (@set + s = 456 ) === MyStruct ((a= 5 - 456 ,))
619620 test_getset_laws (my_x, s, 456 , " 1" )
621+ test_getset_laws (my_identity, 123 , 456 , " 1" )
620622 test_getset_laws (+ , s, 456 , 1.0 )
621623
622624 s = MyStruct ((1 , 2.0 ))
You can’t perform that action at this time.
0 commit comments