www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9706] New: JSON output doesn't contain type of deduced values

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

           Summary: JSON output doesn't contain type of deduced values
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: simendsjo gmail.com


--- Comment #0 from simendsjo <simendsjo gmail.com> 2013-03-12 11:44:40 PDT ---
Ref.: https://github.com/rejectedsoftware/ddox/issues/11

Tested on dmd 2.062 on linux x64 and x86.

Given the following program:
// t.d
module t;
template explicit() {
    enum bool explicit = false;
}
template implicit() {
    enum implicit = false;
}

void main() {}

Compiled with:
dmd -X -Xft.json t.d

t.json doesn't include "deco" : "b" for implicit:

t.json:
[
 {
  "name" : "t",
  "kind" : "module",
  "file" : "t.d",
  "members" : [
   {
    "kind" : "template",
    "name" : "explicit()",
    "line" : 2,
    "parameters" : [],
    "members" : [
     {
      "name" : "explicit",
      "kind" : "variable",
      "line" : 3,
      "storageClass" : [
       "enum"
      ],
      "deco" : "b",
      "init" : "false"
     }
    ]
   },
   {
    "kind" : "template",
    "name" : "implicit()",
    "line" : 5,
    "parameters" : [],
    "members" : [
     {
      "name" : "implicit",
      "kind" : "variable",
      "line" : 6,
      "storageClass" : [
       "enum"
      ],
      "init" : "false"
     }
    ]
   },
   {
    "name" : "main",
    "kind" : "function",
    "line" : 9,
    "deco" : "FZv",
    "endline" : 9
   }
  ]
 }
]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 12 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9706


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-03-12
14:29:28 PDT ---
Hmmm.. a quick hack is to try to infer the type before type is outputted:

void Declaration::jsonProperties(JsonOut *json)
{
    // ...

    if (!type)
    {
        VarDeclaration *vd = this->isVarDeclaration();
        type = vd->init->inferType(NULL);
    }

    json->property("type", "deco", type);

    // ...
}

But that's no good, scope is missing. Anyone more experienced knows how to
handle this?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 12 2013