www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8557] New: AA error with string[string][]

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

           Summary: AA error with string[string][]
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: 10equals2 gmail.com



string[string][]       Dict;    //sure ok.
alias string[string][] dict;    //Error
void main()
{
    Dict                   = [["Cow":"moo" ],["Duck":"quack"]];//cool
    Dict                  ~=  ["Dog":"woof"];                   //No prob.
assert(Dict==[["Cow":"moo"],["Duck":"quack"],["Dog":"woof"]]);//looks legit
    //dict temp              = [["Cow":"moo" ],["Duck":"quack"]];//Error
    //string[string][] temp2 = [["Cow":"moo" ],["Duck":"quack"]];//Error


    //And My favorite one of all:
    //auto temp2 = [["Cow":"moo"],["Duck":"quack"]];  //Error
    auto temp3 = tuple([["Cow":"moo"]]);//works. Variant as well.
}

With everything commented out, Dict works just fine from way up there.
But Tuple, Variant, tls,
Those are the only way to get this to work.

The specific error it gives is:
Error: Integer constant expected instead of "Cow"

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


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



A little reformatted:

import std.typecons: tuple;
string[string][] aa1; // OK
alias string[string][] AA;
void main() {
  aa1 = [["A": "B" ], ["C": "D"]];                     // OK
  aa1 ~= ["E": "F"];                                   // OK
  assert(aa1 == [["A": "B"], ["A": "B"], ["E": "F"]]); // OK
  auto a2 = tuple([["A": "B"]]);                       // OK
  AA a3 = [["A": "B" ], ["C": "D"]];                   // error
  string[string][] a4 = [["A": "B" ], ["C": "D"]];     // error
  auto a5 = [["A": "B"], ["C": "D"]];                  // error
}


It gives the errors:

test.d(9): Error: Integer constant expression expected instead of "A"
test.d(9): Error: Integer constant expression expected instead of "A"
test.d(9): Error: Integer constant expression expected instead of "C"
test.d(9): Error: Integer constant expression expected instead of "C"
test.d(9): Error: cannot implicitly convert expression ([["B"],["D"]]) of type
string[][] to string[string][]
test.d(10): Error: Integer constant expression expected instead of "A"
test.d(10): Error: Integer constant expression expected instead of "A"
test.d(10): Error: Integer constant expression expected instead of "C"
test.d(10): Error: Integer constant expression expected instead of "C"
test.d(10): Error: cannot implicitly convert expression ([["B"],["D"]]) of type
string[][] to string[string][]
test.d(11): Error: Integer constant expression expected instead of "A"
test.d(11): Error: Integer constant expression expected instead of "A"
test.d(11): Error: Integer constant expression expected instead of "C"
test.d(11): Error: Integer constant expression expected instead of "C"

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




This might be a dup of bug 5448.

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


1100110 <10equals2 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |10equals2 gmail.com
            Version|unspecified                 |D2




 This might be a dup of bug 5448.
It is not *exactly* the same, but they do overlap. Thank you for pointing that out. Something not mentioned in bug 5448 is that alias does not work with AA, Although that might be implied. If you feel that this cuts the difference too close, either close it or I will. I apologize, I didn't quite understand all of the reasons it would not work when I opened the ticket. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 18 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8557






 This might be a dup of bug 5448.
It is not *exactly* the same, but they do overlap. Thank you for pointing that out. Something not mentioned in bug 5448 is that alias does not work with AA, Although that might be implied. If you feel that this cuts the difference too close, either close it or I will. I apologize, I didn't quite understand all of the reasons it would not work when I opened the ticket.
To me, both this and bug 5448 have the same root that a problem of semantic analysis for the initializer of variable declaration. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 19 2012