Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove let-binding workarounds #2012

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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