Better position of assignment errors.
This commit is contained in:
parent
6a740a9fa1
commit
cfbf0397a6
@ -1758,7 +1758,7 @@ fn make_assignment_stmt(
|
|||||||
}
|
}
|
||||||
Expr::Property(_, _) => None,
|
Expr::Property(_, _) => None,
|
||||||
// Anything other than a property after dotting (e.g. a method call) is not an l-value
|
// Anything other than a property after dotting (e.g. a method call) is not an l-value
|
||||||
ref e => Some(e.start_position()),
|
ref e => Some(e.position()),
|
||||||
},
|
},
|
||||||
Expr::Index(x, term, _) | Expr::Dot(x, term, _) => match x.lhs {
|
Expr::Index(x, term, _) | Expr::Dot(x, term, _) => match x.lhs {
|
||||||
Expr::Property(_, _) => unreachable!("unexpected Expr::Property in indexing"),
|
Expr::Property(_, _) => unreachable!("unexpected Expr::Property in indexing"),
|
||||||
@ -1767,7 +1767,7 @@ fn make_assignment_stmt(
|
|||||||
},
|
},
|
||||||
Expr::Property(_, _) if parent_is_dot => None,
|
Expr::Property(_, _) if parent_is_dot => None,
|
||||||
Expr::Property(_, _) => unreachable!("unexpected Expr::Property in indexing"),
|
Expr::Property(_, _) => unreachable!("unexpected Expr::Property in indexing"),
|
||||||
e if parent_is_dot => Some(e.start_position()),
|
e if parent_is_dot => Some(e.position()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1819,8 +1819,10 @@ fn make_assignment_stmt(
|
|||||||
op_pos,
|
op_pos,
|
||||||
)),
|
)),
|
||||||
// expr[???] = rhs, expr.??? = rhs
|
// expr[???] = rhs, expr.??? = rhs
|
||||||
ref expr => Err(PERR::AssignmentToInvalidLHS("".to_string())
|
ref expr => {
|
||||||
.into_err(expr.start_position())),
|
Err(PERR::AssignmentToInvalidLHS("".to_string())
|
||||||
|
.into_err(expr.position()))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(err_pos) => {
|
Some(err_pos) => {
|
||||||
@ -1835,7 +1837,7 @@ fn make_assignment_stmt(
|
|||||||
)
|
)
|
||||||
.into_err(op_pos)),
|
.into_err(op_pos)),
|
||||||
// expr = rhs
|
// expr = rhs
|
||||||
_ => Err(PERR::AssignmentToInvalidLHS("".to_string()).into_err(lhs.start_position())),
|
_ => Err(PERR::AssignmentToInvalidLHS("".to_string()).into_err(lhs.position())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user