Skip to content

Commit c38770d

Browse files
committed
Don't bother running ?? again during augmented assignment
If we've reached the assignment stage during x ??= y, we know that x is nullish (otherwise we would have returned it earlier). But we've been running "x = (x ?? y)", even though we know that the right hand side will be y in this case.
1 parent 2e3b5c2 commit c38770d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

M2/Macaulay2/d/evaluate.d

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,8 +1438,11 @@ augmentedAssignmentFun(x:augmentedAssignmentCode):Expr := (
14381438
else return r)
14391439
else return r);
14401440
-- if not, use default behavior
1441-
c := Code(binaryCode(s, Code(evaluatedCode(lexpr, codePosition(x.lhs))),
1442-
x.rhs, x.position));
1441+
c := (
1442+
if s.word.name === "??" then x.rhs
1443+
else Code(binaryCode(s,
1444+
Code(evaluatedCode(lexpr, codePosition(x.lhs))),
1445+
x.rhs, x.position)));
14431446
when x.lhs
14441447
is y:globalMemoryReferenceCode do (
14451448
r := eval(c);

0 commit comments

Comments
 (0)