| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
April 04, 2009 Variant[string] associative array ... fail? | ||||
|---|---|---|---|---|
| ||||
Hi everyone,
This code works...
----------------------
import std.variant;
import std.stdio;
void main()
{
Variant v;
v = "hello";
writeln(v);
}
----------------------
But this code does not...
----------------------
import std.variant;
import std.stdio;
void main()
{
Variant[string] v;
v["there"] = "hello";
writeln(v["there"]);
}
----------------------
...resulting in this runtime failure:
core.exception.RangeError@Var(6): Range violation
What did I do wrong?
Using Digital Mars D Compiler v2.027, on OS X 10.5.6.
Thanks,
--Eljay
| ||||
April 04, 2009 Re: Variant[string] associative array ... fail? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Eljay | Is it this one? http://d.puremagic.com/issues/show_bug.cgi?id=2451 | |||
April 04, 2009 Re: Variant[string] associative array ... fail? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Eljay | Eljay wrote: > Hi everyone, > > This code works... > ---------------------- > import std.variant; > import std.stdio; > void main() > { > Variant v; > v = "hello"; > writeln(v); > } > ---------------------- > > But this code does not... > ---------------------- > import std.variant; > import std.stdio; > void main() > { > Variant[string] v; > v["there"] = "hello"; > writeln(v["there"]); > } > ---------------------- > ...resulting in this runtime failure: > core.exception.RangeError@Var(6): Range violation > > What did I do wrong? > > Using Digital Mars D Compiler v2.027, on OS X 10.5.6. > > Thanks, > --Eljay Hey Eljay, thanks for being around :o). It's good you raise scrutiny about the dynamic style of coding in D. The code is correct but subject to a compiler bug: http://d.puremagic.com/issues/show_bug.cgi?id=2451 I just voted that up (it's supposed to raise its informal importance), you may want to as well. Andrei | |||
April 04, 2009 Re: Variant[string] associative array ... fail? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | > Hey Eljay, thanks for being around :o). It's good you raise scrutiny about the dynamic style of coding in D. The code is correct but subject to a compiler bug:
>
> http://d.puremagic.com/issues/show_bug.cgi?id=2451
>
> I just voted that up (it's supposed to raise its informal importance), you may want to as well.
Thanks Andrei!
I'll put in in my vote. :-)
I'm relieved that my program is correct (as per my understanding of the documentation). And that the compiler bug will be fixed in due course -- I'm very patient.
Sincerely,
--Eljay
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply