Skip to content

Commit 269984a

Browse files
authored
Add missing parentheses around constructor used as indexing op (#1740)
1 parent 6436dc9 commit 269984a

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
+ Support sugared form of coercions in let bindings (#1739, @gpetiot)
1414

15+
+ Add missing parentheses around constructor used as indexing op (#1740, @gpetiot)
16+
1517
#### Changes
1618

1719
#### New features

lib/Ast.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2286,6 +2286,10 @@ end = struct
22862286
, {pexp_desc= Pexp_construct _ | Pexp_variant _; _} )
22872287
when e == exp ->
22882288
true
2289+
| ( Exp {pexp_desc= Pexp_apply (e0, ((_, e) :: _ as args)); _}
2290+
, {pexp_desc= Pexp_construct _; _} )
2291+
when e == exp && Option.is_some (Indexing_op.get_sugar e0 args) ->
2292+
true
22892293
| ( Exp {pexp_desc= Pexp_apply (op1, [(_, e)]); _}
22902294
, {pexp_desc= Pexp_apply (_, [(_, x); _]); _} )
22912295
when e == exp && Exp.is_prefix op1 && Exp.exposed_left x ->

test/passing/tests/index_op.ml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,27 @@ let _ = Array.unsafe_get [||] (-8)
172172
let _ = Bigarray.Genarray.get x [||] (-8)
173173

174174
let _ = Bigarray.Genarray.unsafe_get x [||] (-8)
175+
176+
let _ = [%p (Some).(tickers)]
177+
178+
let _ = [%p (Explicit).(0 / 2)]
179+
180+
let _ = [%p Some.(tickers)]
181+
182+
let _ = [%p Explicit.(0 / 2)]
183+
184+
let _ = (Some).(tickers)
185+
186+
let _ = (Explicit).(0 / 2)
187+
188+
let _ = Some.(tickers)
189+
190+
let _ = Explicit.(0 / 2)
191+
192+
let _ = f (Some).(tickers)
193+
194+
let _ = f (Explicit).(0 / 2)
195+
196+
let _ = f Some.(tickers)
197+
198+
let _ = f Explicit.(0 / 2)

0 commit comments

Comments
 (0)