@@ -272,11 +272,12 @@ let operator_precedence operator =
272
272
| ":=" -> 1
273
273
| "||" -> 2
274
274
| "&&" -> 3
275
- | "==" | "===" | "<" | ">" | "!=" | "<>" | "!==" | "<=" | ">=" | "|>" -> 4
276
- | "+" | "+." | "-" | "-." | "++" -> 5
277
- | "*" | "*." | "/" | "/." | "%" -> 6
278
- | "**" -> 7
279
- | "#" | "##" | "->" -> 8
275
+ | "^" -> 4
276
+ | "==" | "===" | "<" | ">" | "!=" | "<>" | "!==" | "<=" | ">=" | "|>" -> 5
277
+ | "+" | "+." | "-" | "-." | "++" -> 6
278
+ | "*" | "*." | "/" | "/." | "%" -> 7
279
+ | "**" -> 8
280
+ | "#" | "##" | "->" -> 9
280
281
| _ -> 0
281
282
282
283
let is_unary_operator operator =
@@ -295,15 +296,17 @@ let is_unary_expression expr =
295
296
true
296
297
| _ -> false
297
298
298
- (* TODO: tweak this to check for ghost ^ as template literal *)
299
299
let is_binary_operator operator =
300
300
match operator with
301
301
| " :=" | " ||" | " &&" | " ==" | " ===" | " <" | " >" | " !=" | " !==" | " <=" | " >="
302
302
| " |>" | " +" | " +." | " -" | " -." | " ++" | " *" | " *." | " /" | " /." | " **"
303
- | "->" | "<>" | "%" ->
303
+ | "->" | "<>" | "%" | "^" ->
304
304
true
305
305
| _ -> false
306
306
307
+ let not_ghost_operator operator (loc : Location.t ) =
308
+ is_binary_operator operator && not (loc.loc_ghost && operator = " ++" )
309
+
307
310
let is_binary_expression expr =
308
311
match expr.pexp_desc with
309
312
| Pexp_apply
@@ -315,9 +318,7 @@ let is_binary_expression expr =
315
318
};
316
319
args = [(Nolabel , _operand1); (Nolabel , _operand2)];
317
320
}
318
- when is_binary_operator operator
319
- && not (operator_loc.loc_ghost && operator = " ++" )
320
- (* template literal *) ->
321
+ when not_ghost_operator operator operator_loc ->
321
322
true
322
323
| _ -> false
323
324
0 commit comments