Skip to content

Commit

Permalink
Revert "fix Issue 16193 - opApply() doesn't heap allocate closure"
Browse files Browse the repository at this point in the history
This reverts commit f7819c8.

Fixes issue 16678
  • Loading branch information
Dicebot committed Nov 10, 2016
1 parent 9dfa50e commit aac715f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 83 deletions.
27 changes: 0 additions & 27 deletions changelog.dd
Expand Up @@ -8,39 +8,12 @@ $(BUGSTITLE Language Changes,
)

$(BUGSTITLE Compiler Changes,
$(LI $(RELATIVE_LINK2 iteration_closure, Assumes opApply delegate parameter escapes unless marked `scope`))
)

$(BUGSTITLE Language Changes,
)

$(BUGSTITLE Compiler Changes,
$(LI $(LNAME2 iteration_closure, Assumes opApply delegate parameter escapes unless marked `scope`)

$(P This breaking change was required to fix bug with `@safe` violation: $(BUGZILLA 16193).)

$(P To list all places where closure may be allocated after the change, use `-transition=safe`
compiler switch.)

$(P Example:)

---
struct S1 {
int opApply(int delegate(int) dg);
}

struct S2 {
int opApply(scope int delegate(int) dg);
}

void foo() {
foreach(i; S1.init) { // will allocate closure
}
foreach(i; S2.init) { // won't allocate closure
}
}
---
)
)

Macros:
Expand Down
11 changes: 0 additions & 11 deletions src/statementsem.d
Expand Up @@ -1447,17 +1447,6 @@ private extern (C++) final class StatementSemanticVisitor : Visitor
}
else
{
if (global.params.vsafe)
{
fprintf(
global.stdmsg,
"%s: To enforce @safe compiler allocates a closure unless the opApply() uses 'scope'\n",
loc.toChars()
);
fflush(global.stdmsg);
}
fld.tookAddressOf = 1;

assert(tab.ty == Tstruct || tab.ty == Tclass);
assert(sapply);
/* Call:
Expand Down
45 changes: 0 additions & 45 deletions test/fail_compilation/test16193.d

This file was deleted.

0 comments on commit aac715f

Please sign in to comment.