Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into splitOffPartsOfSing…
Browse files Browse the repository at this point in the history
…lePassCompiler
  • Loading branch information
keyboardDrummer committed Jun 4, 2024
2 parents f0db327 + 7522f29 commit 3fe2efd
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ public abstract partial class SinglePassCodeGenerator {
var e = (LambdaExpr)expr;

IVariable receiver = null;
if (enclosingMethod is { IsTailRecursive: true } || enclosingFunction is { IsTailRecursive: true }) {
if (thisContext != null && (enclosingMethod is { IsTailRecursive: true } || enclosingFunction is { IsTailRecursive: true })) {
var name = ProtectedFreshId("_this");
var ty = ModuleResolver.GetThisType(e.tok, thisContext);
receiver = new LocalVariable(RangeToken.NoToken, name, ty, false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4756,7 +4756,6 @@ private class ArrayLvalueImpl : ILvalue {
return result;
}


private void CompileTypeTest(TypeTestExpr expr, bool inLetExprBody, ConcreteSyntaxTree wr, ref ConcreteSyntaxTree wStmts) {
var fromType = expr.E.Type;
if (fromType.IsSubtypeOf(expr.ToType, false, false)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// RUN: %testDafnyForEachCompiler --refresh-exit-code=0 "%s"

function Loop(xs: seq<()>): ()
{
if |xs| == 0
then ()
else
var _: bool -> bool := e => e;
Loop(xs[1..])
}

method Main(){
print Loop([(), ()]), "\n";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHECK: error\[E0277\]: the trait bound
1 change: 1 addition & 0 deletions docs/dev/news/5524.fix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Only guard `this` when eliminating tail calls, if possible

0 comments on commit 3fe2efd

Please sign in to comment.