Skip to content

Commit

Permalink
fix(compiler): Report binop locations properly (#1271)
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed May 29, 2022
1 parent fcdfc2a commit 4b9dd9c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions compiler/src/parsing/ast_helper.re
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,23 @@ module Exp = {
// because the parser would expect a number). It's easier to just parse it
// as division and have this action decide that it's actually a rational.
let binop = (~loc=?, ~attributes=?, a, b) => {
// Locations of nested binops are difficult to compute in the parser so we
// just set the location manually here
let loc =
Location.(
Option.map(
loc =>
switch (b) {
| [{pexp_loc: {loc_start}}, {pexp_loc: {loc_end}}] => {
...loc,
loc_start,
loc_end,
}
| _ => failwith("Impossible: not a binop")
},
loc,
)
);
switch (a, b) {
| (
{pexp_desc: PExpId({txt: IdentName({txt: "/"})})},
Expand Down

0 comments on commit 4b9dd9c

Please sign in to comment.