D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8073 - Regression (git) Error: undefined identifier __result
Summary: Regression (git) Error: undefined identifier __result
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 regression
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-05-09 09:43 UTC by Leandro Lucarella
Modified: 2015-06-09 05:11 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Leandro Lucarella 2012-05-09 09:43:36 UTC
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 Leandro Lucarella 2012-05-09 09:44:22 UTC
Oh, and it only happens with -release!
Comment 2 Don 2012-05-11 21:54:17 UTC
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 Kenji Hara 2012-05-13 21:35:48 UTC
(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 github-bugzilla 2012-05-13 21:39:07 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/594aa562f8876bd8ea2f24d58a0f4a01b8d3765a
fix Issue 8073 - Regression (git) Error: undefined identifier __result

https://github.com/D-Programming-Language/dmd/commit/8f28a6bef8ed024d8f9cf5709c50a9f060c34798
Merge pull request #946 from 9rnsr/fix8073

Issue 8073 - Regression (git) Error: undefined identifier __result