Bug 8073 – Regression (git) Error: undefined identifier __result

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-09T09:43:00Z
Last change time
2015-06-09T05:11:46Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
leandro.lucarella

Comments

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
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