File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed
Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -187,9 +187,29 @@ fn traverse_function(
187187fn parse_expression_and_find_mutants ( function : & FunctionEnv < ' _ > , exp : & ExpData ) -> Vec < Mutant > {
188188 let convert_exps_to_explocs = |exps : & [ Exp ] | -> Vec < ExpLoc > {
189189 exps. iter ( )
190- . map ( |e| ExpLoc {
191- exp : e. clone ( ) ,
192- loc : function. module_env . env . get_node_loc ( e. node_id ( ) ) ,
190+ . map ( |e| {
191+ // NOTE: This is a workaround for a compiler bug.
192+ // For Deref operations in compound assignments, the Move compiler seems to
193+ // assign the span of the entire compound assignment to the Deref node.
194+ // We use the inner expression's location instead to get the correct span.
195+ //
196+ // TODO: When https://github.com/aptos-labs/aptos-core/pull/17841 is in a release branch,
197+ // we can remove the loc var and only leave "function.module_env.env.get_node_loc(e.node_id())"
198+ // for the "loc" field. Then update the deps to use the new release branch.
199+ let loc = if let ExpData :: Call ( _, Operation :: Deref , inner_exps) = e. as_ref ( ) {
200+ if let Some ( inner_exp) = inner_exps. first ( ) {
201+ function. module_env . env . get_node_loc ( inner_exp. node_id ( ) )
202+ } else {
203+ function. module_env . env . get_node_loc ( e. node_id ( ) )
204+ }
205+ } else {
206+ function. module_env . env . get_node_loc ( e. node_id ( ) )
207+ } ;
208+
209+ ExpLoc {
210+ exp : e. clone ( ) ,
211+ loc,
212+ }
193213 } )
194214 . collect :: < Vec < ExpLoc > > ( )
195215 } ;
You can’t perform that action at this time.
0 commit comments