Skip to content

Commit

Permalink
Remove let-binding workarounds (#2012)
Browse files Browse the repository at this point in the history
The bug which necessitated the workaround was fixed in #1928.
  • Loading branch information
kostmo authored Jul 6, 2024
1 parent 54bf8f9 commit 6087be5
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 25 deletions.
5 changes: 1 addition & 4 deletions data/scenarios/Challenges/Ranching/_capture/opponent.sw
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,9 @@ Iterate 4 times (once for each direction)
def countBlocked = \n.
if (n > 0) {
isBlocked <- blocked;
// This assignment has to happen before the recursive
// "countBlocked" call due to #1032
let localBlockCount = boolToInt isBlocked in
turn left;
lastCount <- countBlocked $ n - 1;
return $ lastCount + localBlockCount;
return $ lastCount + boolToInt isBlocked;
} {
return 0;
}
Expand Down
6 changes: 1 addition & 5 deletions data/scenarios/Challenges/Ranching/_powerset/setup.sw
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,9 @@ Fisher-Yates would be more efficient, but requires a physical array.
def naiveRandomStack = \valueFunc. \maxval. \bitmask. \n.
val <- if (n > 1) {
nextRandomVal <- getUnusedRandom maxval bitmask;

// Recursion bug workaround (see #1032):
let blahNextRandomVal = nextRandomVal in

let newBitmask = bitmask + shiftLeft 1 nextRandomVal in
naiveRandomStack valueFunc maxval newBitmask $ n - 1;
return blahNextRandomVal;
return nextRandomVal;
} {
// We're at the peak of the stack.
// Now we unwind it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ def getIndexesTotal = \boardWidth. \boardHeight. \n.
let idx = n - 1 in
teleport self (idx/boardHeight, -(mod idx boardWidth));
valueHere <- getValueHere;

// This reassignment has to happen before the
// recursive call due to #1032
let valueHereBlah = valueHere in
runningTotal <- getIndexesTotal boardWidth boardHeight $ n - 1;
return $ valueHereBlah + runningTotal;
return $ valueHere + runningTotal;
} {
return 0;
}
Expand Down
6 changes: 1 addition & 5 deletions data/scenarios/Challenges/_gallery/setup.sw
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,9 @@ Fisher-Yates would be more efficient, but requires a physical array.
def naiveRandomStack = \valueFunc. \maxval. \bitmask. \n.
val <- if (n > 1) {
nextRandomVal <- getUnusedRandom maxval bitmask;

// Recursion bug workaround (see #1032):
let blahNextRandomVal = nextRandomVal in

let newBitmask = bitmask + shiftLeft 1 nextRandomVal in
naiveRandomStack valueFunc maxval newBitmask $ n - 1;
return blahNextRandomVal;
return nextRandomVal;
} {
// We're at the peak of the stack.
// Now we unwind it.
Expand Down
7 changes: 1 addition & 6 deletions data/scenarios/Challenges/_lights-out/assistant.sw
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,8 @@ def prepareBoardAllRows = \abortFunc. \boardWidth. \rowIdx.
return (0, 0);
} {
advanceRowViaTeleport;

// This reassignment has to happen before the recursive
// "prepareBoardAllRows" call due to #1032
let rowCommonCountFoo = rowCommonCount in
totalCommonCount <- prepareBoardAllRows abortFunc boardWidth $ rowIdx - 1;

return $ sumTuples rowCommonCountFoo totalCommonCount
return $ sumTuples rowCommonCount totalCommonCount
}
} {
return (0, 0);
Expand Down

0 comments on commit 6087be5

Please sign in to comment.