Hello,
I tried to create a static lib from phobos and druntime then generate header files but I found some problems with it.
-H is stripping bodies from ref functions so return type cannot be deduced.
same for ref return functions.
exmaple from phobos/std/typecons.d
@property ref return T refCountedPayload();
Comment #1 by satoshi — 2016-10-17T08:45:39Z
When I create function like:
class TestClass {
int aa;
auto ref foo() {
return aa;
}
}
It is exported correctly, but when I create it like:
class TestClass {
int aa;
ref foo() { // without auto
return aa;
}
}
it is exported like:
class TestClass {
int aa;
ref foo(); // Cannot deduce return type
}
Comment #2 by satoshi — 2016-10-25T13:09:30Z
() @trusted {
}
block is rewritten as
() {
}
what is wrong
Comment #3 by satoshi — 2016-10-25T13:10:14Z
methods marked as return, e.g.
void foo() return {
}
are exported in wring way.
Comment #4 by satoshi — 2016-10-25T13:13:26Z
class Foo {
protected void method42() {
}
}
class Bar : Foo {
void method42() {
}
}
Bar.method42() does not override any function
Comment #5 by satoshi — 2016-10-25T13:24:29Z
struct Foo(size_t Size = 42 / magic()) {
}
size_t magic() {
return 42;
}
This cannot resolve magic() function at compile time.
Comment #6 by satoshi — 2016-10-25T13:37:17Z
class Foo {
immutable(Foo) Dummy = new immutable(Foo);
private immutable pure nothrow @nogc @safe this() {
}
}
this() has stripped body and compiler thrown an error
"cannot be constructed at compile time, because the constructor has no available source code"
Comment #7 by satoshi — 2016-10-25T13:59:34Z
Attributes are stripped from destrutors.
e.g.
~this() @trusted { ... }
to
~this();
Comment #8 by satoshi — 2016-12-21T20:12:47Z
Can someone fix this bug, please?
I am not able to release any alpha version of my library until this bug will not be fixed.
Comment #9 by jj_1337 — 2016-12-28T11:12:22Z
Voted this up with 20 votes as I see this as pretty important to be fixed as people can depend on large interface file generation and if you have to manually fix a lot of places like this then it's a lot of work that has to be put into it.
The compiler should be able to do this by default.
Comment #10 by dhasenan — 2016-12-28T16:15:35Z
dmd's json output suffers from the same problems.
Comment #11 by dhasenan — 2016-12-28T23:26:23Z
https://github.com/dlang/dmd/pull/6382 addresses by including function bodies.
The causes for the header and json issues are separate, and with json output, you can at least construct the mangled version and demangle to get the necessary information.
It's suboptimal to include function bodies for these functions in general. With voldemort types, it's required; however, in all other cases, the compiler could identify the actual type in use and report that. That can be handled by moving header generation to follow semantic3 (currently it's just after parsing). However, that would require filtering out certain symbols that are added during semantic (for instance, __xdtor and a set of anonymous RTInfo!(type) fields).
Comment #12 by github-bugzilla — 2017-01-13T11:29:38Z
I found more bugs.
return attribute is generated as prefix, but it's not valid for compiler.
generated:
ref return rename()() {...}
should be:
ref rename()() return { ... }
next bug:
generated:
if (a < 2 | b > 7)
should be:
if ((a < 2) | (b > 7))
Comment #15 by satoshi — 2017-02-24T23:56:22Z
() @trusted {
}();
is generated as:
() {
}();
Comment #16 by satoshi — 2017-02-28T16:24:33Z
alias foo = (a, b) => less(b, a);
is rewritten asi:
alias foo = (__T42, __T43)(a, b) {
return less(b, a);
}
Variable types are missing
Comment #17 by github-bugzilla — 2017-03-22T12:21:02Z
Comment #18 by dlang-bugzilla — 2017-06-26T01:15:33Z
Satoshi, please file extant cases as new issues and close this one. Multiple bugs filed under one issue make it difficult to track which ones are still unfixed, and which one any particular pull request fixes.