Thread overview
[Issue 8557] New: AA error with string[string][]
Aug 18, 2012
1100110
Aug 18, 2012
Kenji Hara
Aug 19, 2012
1100110
Aug 19, 2012
Kenji Hara
August 18, 2012
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


--- Comment #0 from 1100110 <10equals2@gmail.com> 2012-08-18 01:45:53 PDT ---
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: -------
August 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8557


bearophile_hugs@eml.cc changed:

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


--- Comment #1 from bearophile_hugs@eml.cc 2012-08-18 05:51:44 PDT ---
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: -------
August 18, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8557



--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> 2012-08-18 13:23:42 PDT ---
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: -------
August 19, 2012
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


--- Comment #3 from 1100110 <10equals2@gmail.com> 2012-08-18 19:36:09 PDT ---
(In reply to comment #2)
> 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: -------
August 19, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8557



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2012-08-19 01:03:40 PDT ---
(In reply to comment #3)
> (In reply to comment #2)
> > 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: -------