Bug 7262 – 'used before set' error with no line number

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-01-09T18:03:00Z
Last change time
2012-02-17T03:41:15Z
Keywords
diagnostic, patch, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-01-09T18:03:52Z
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.
Comment #1 by k.hara.pg — 2012-01-09T19:09:39Z
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
Comment #2 by yebblies — 2012-02-17T03:41:15Z