Thread overview
[Issue 4477] New: JSON output for function definitions includes insufficient type information
Jul 17, 2010
Chris Wright
Mar 14, 2012
Matt Peterson
Jan 21, 2013
Walter Bright
July 17, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4477

           Summary: JSON output for function definitions includes
                    insufficient type information
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: dhasenan@gmail.com


--- Comment #0 from Chris Wright <dhasenan@gmail.com> 2010-07-17 09:35:15 PDT ---
Consider:
---
class A {}
void foo(A a) {}
void bar(ref A a) {}
void frob(A a = null) {}
---

dmd -X on this outputs the following type information for functions foo, bar,
and frob:
"type": "void(A a)" // foo
"type": "void(ref A a)" // bar
"type": "void(A a = cast(A)null)" // frob

There are a few issues with this:
 - To determine what the arguments are, I need to parse a string. This is
undesirable. (Additionally, I can't parse it with regular expressions, since a
function might take a delegate or templated type as a parameter.)
 - Even if I go through the trouble of parsing the string, I *still* only have
the type name. Not even the fully qualified name. So I have no idea where to
locate the type definition.
 - The names of function parameters are included, making it harder to find the
types.
 - Default parameters are also included here.

Suggested solution: change "type" property to an object. For user-defined types, include at a minimum the fully qualified name, as given by demangle(T.mangleof). For function types, include an array of parameter objects, each of which can include a name, a type, a storage class, and a default value.

{
"name": "frob",
"type": {
"return-value:" "void",
"parameters": [
{
"name": "a",
"type": "test.A",
"storage-class": "in",
"default-value": "cast(test.A)null"
}
]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=4477


Matt Peterson <revcompgeek@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |revcompgeek@gmail.com


--- Comment #1 from Matt Peterson <revcompgeek@gmail.com> 2012-03-14 15:42:23 PDT ---
https://github.com/D-Programming-Language/dmd/pull/813

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 21, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=4477


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
            Version|D1 & D2                     |D2
         Resolution|                            |FIXED


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2013-01-21 00:02:39 PST ---
https://github.com/D-Programming-Language/dmd/pull/1527

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