File tree Expand file tree Collapse file tree 3 files changed +38
-5
lines changed
Expand file tree Collapse file tree 3 files changed +38
-5
lines changed Original file line number Diff line number Diff line change 11unreleased
22----------
33
4+ - Fix infinite loop when duplicate attributes are present, raising
5+ an error instead (#613 , @ceastlund , @patricoferris )
6+
470.37.0
58------
69
Original file line number Diff line number Diff line change @@ -366,7 +366,7 @@ let handle_attr_replace_once context attrs item base_ctxt : 'a option t =
366366 | [] -> return (false , Rule.Attr_replace.Parsed_payload_list. [] )
367367 | x :: xs ->
368368 (if Attribute.Context. equal context (Attribute. context x) then
369- Attribute. get_res x item |> of_result ~default: None
369+ return @@ Attribute. get x item
370370 else return None )
371371 >> = fun p ->
372372 get_attr_payloads xs >> | fun (any_attrs , ps ) ->
@@ -377,10 +377,10 @@ let handle_attr_replace_once context attrs item base_ctxt : 'a option t =
377377 if any_attrs then
378378 Some
379379 ( (payloads, errors) >> = fun payloads ->
380- Attribute. remove_seen_res context
381- ( Rule.Attr_replace.Attribute_list. to_packed_list a.attributes)
382- item
383- |> of_result ~default: item
380+ return
381+ @@ Attribute. remove_seen context
382+ ( Rule.Attr_replace.Attribute_list. to_packed_list a.attributes)
383+ item
384384 >> | fun item -> a.expand ~ctxt: base_ctxt item payloads )
385385 else None )
386386 in
Original file line number Diff line number Diff line change @@ -123,3 +123,33 @@ Test that the "attr_multiple_replace" infrastructure works.
123123 > EOF
124124 $ ./ driver. exe test. ml
125125 let _ = ((prefix_foo_suffix)[@ alert " -1" ][@ alert " -2" ][@ alert " -3" ])
126+
127+ Demonstrate error when multiple instances of one attribute are passed.
128+ $ cat > test. ml << EOF
129+ > let _ =
130+ > foo
131+ > [@ prefix " prefix_" ]
132+ > [@ suffix " _suffix" ]
133+ > [@ suffix " _again" ]
134+ > EOF
135+ $ ./ driver. exe test. ml
136+ File " test.ml" , line 5 , characters 4 -10:
137+ 5 | [@ suffix " _again" ]
138+ ^^^^^^
139+ Error: Duplicated attribute
140+ [1 ]
141+
142+ Demonstrate error when multiple instances of one attribute are passed and
143+ no other attributes are available.
144+ $ cat > test. ml << EOF
145+ > let _ =
146+ > foo
147+ > [@ suffix " _suffix" ]
148+ > [@ suffix " _again" ]
149+ > EOF
150+ $ ./ driver. exe test. ml
151+ File " test.ml" , line 4 , characters 4 -10:
152+ 4 | [@ suffix " _again" ]
153+ ^^^^^^
154+ Error: Duplicated attribute
155+ [1 ]
You can’t perform that action at this time.
0 commit comments