Bug 4477 – JSON output for function definitions includes insufficient type information

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-07-17T09:35:00Z
Last change time
2013-01-21T00:02:39Z
Keywords
json
Assigned to
nobody
Creator
dhasenan

Comments

Comment #0 by dhasenan — 2010-07-17T09:35:15Z
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" } ]
Comment #1 by ricochet1k — 2012-03-14T15:42:23Z
Comment #2 by bugzilla — 2013-01-21T00:02:39Z