www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7262] New: 'used before set' error with no line number

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7262

           Summary: 'used before set' error with no line number
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



import std.algorithm: map;
import std.typecons: tuple;
int foo() {
    return 0;
}
void main() {
    auto bars = map!(n => tuple(foo(), n))([10]);
    auto spam = bars.front[1];
}


Compiling with:
dmd -O test.d


DMD 2.058head gives:

Error: variable __tup818 used before set

Note the lack of error line number.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7262


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch, rejects-valid



It is tuple + indexing + optimization bug.

Workaround:

void main() {
   auto bars = map!(n => tuple(foo(), n))([10]);
   auto spam_tup = bars.front;//[1];   // save whole tuple temporarily
   auto spam = spam_tup[1];            // get an element of tuple
}

It will be fixed by merging:
https://github.com/D-Programming-Language/dmd/pull/609

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7262


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |yebblies gmail.com
         Resolution|                            |FIXED



Works for me, presumably fixed by the fix to issue 4940

https://github.com/D-Programming-Language/dmd/commit/d6ede2edc28c94b6b3372eb1301cf300b0860eb6

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 17 2012