mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 06:14:59 +00:00
Fix a bug which caused the compiler to miscompile
Estimated hours taken: 8 Fix a bug which caused the compiler to miscompile value_number__substitute_access_vns. compiler/cse_detection.m: In find_bind_var_for_cse, ensure that if the variable which we are trying to hoist is bound to a different functor than the one we're searching for, then we stop searching for a match. This is necessary, because the code that checks for a match assumes that the variable we're trying to hoist has not yet been bound.
This commit is contained in:
@@ -555,6 +555,17 @@ find_bind_var_for_cse([GoalPair0 | Goals0], Substitution0, Var, MaybeUnify0,
|
||||
Substitution = Substitution2,
|
||||
CseInfo = CseInfo0,
|
||||
MaybeUnify = MaybeUnify0
|
||||
;
|
||||
%
|
||||
% if the variable was bound, but the deconstruction wasn't
|
||||
% similar, then stop searching
|
||||
%
|
||||
Term = term__functor(_, _, _)
|
||||
->
|
||||
Goals = [Goal0 - GoalInfo | Goals0],
|
||||
Substitution = Substitution2,
|
||||
CseInfo = CseInfo0,
|
||||
MaybeUnify = no
|
||||
;
|
||||
find_bind_var_for_cse(Goals0, Substitution2, Var,
|
||||
MaybeUnify0, CseInfo0, CseInfo,
|
||||
|
||||
Reference in New Issue
Block a user