Comment #0 by leandro.lucarella — 2012-05-09T09:43:36Z
A regression was introduced in the latest D1 changeset:
b75d921 merge D1 pull #529
https://github.com/D-Programming-Language/dmd/commit/b75d921
When compiling tango I get this error which didn't happened before:
./tango/io/vfs/ZipFolder.d(672): Error: undefined identifier __result
Unfortunately I couldn't come up with a minimal test case yet, but since I know the exact commit that caused it, maybe it is easy enough to be fix by somebody familiar with what that patch does.
Comment #1 by leandro.lucarella — 2012-05-09T09:44:22Z
Oh, and it only happens with -release!
Comment #2 by clugdbug — 2012-05-11T21:54:17Z
Reduced test case applies also to D2, and doesn't require -release:
===========================================
struct Container8073
{
int opApply (int delegate(ref int) dg) { return 0; }
}
class Bug8073
{
int foo()
out { } body
{
Container8073 ww;
foreach( xxx ; ww ) { }
return 7;
}
}
===========================================
It's because with func->result is used for 'foreach' as well as for out contracts. If it's used in a foreach, it currently doesn't get added to the out contract scope 'scout'.
In statement.c, ForeachStatement and ReturnStatement need
if (func->scout) func->scout->insert(vresult);
in both places where they create vresult.
Comment #3 by k.hara.pg — 2012-05-13T21:35:48Z
(In reply to comment #2)
> Reduced test case applies also to D2, and doesn't require -release:
> ===========================================
> struct Container8073
> {
> int opApply (int delegate(ref int) dg) { return 0; }
> }
>
> class Bug8073
> {
> int foo()
> out { } body
> {
> Container8073 ww;
> foreach( xxx ; ww ) { }
>
> return 7;
> }
> }
> ===========================================
> It's because with func->result is used for 'foreach' as well as for out
> contracts. If it's used in a foreach, it currently doesn't get added to the out
> contract scope 'scout'.
>
> In statement.c, ForeachStatement and ReturnStatement need
> if (func->scout) func->scout->insert(vresult);
> in both places where they create vresult.
Thanks for your reduced test case and description! I have posted a D2 pull to fix it:
https://github.com/D-Programming-Language/dmd/pull/946
Comment #4 by github-bugzilla — 2012-05-13T21:39:07Z