D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4225 - mangle.c:81: char* mangle(Declaration*): Assertion `fd && fd->inferRetType' failed.
Summary: mangle.c:81: char* mangle(Declaration*): Assertion `fd && fd->inferRetType' f...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2010-05-23 07:37 UTC by nfxjfg
Modified: 2014-08-10 12:54 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description nfxjfg 2010-05-23 07:37:44 UTC
$ cat bla.d 
struct Foo {
    const x = Foo();

    static Foo opCall() {
        return Foo.init;
    }
}

$ dmd bla.d
::mangle(x)
dmd: mangle.c:81: char* mangle(Declaration*): Assertion `fd && fd->inferRetType' failed.
Aborted

Tested with dmd 1.061, where I removed the commented printf() in mangle.c line 37.
Comment 1 Don 2010-05-23 22:10:51 UTC
Probably related to bug 2080, since both involve type inference.
Comment 2 Walter Bright 2011-04-10 21:16:38 UTC
A partial fix:

https://github.com/D-Programming-Language/dmd/commit/1fc2fdb5fa9831eee2e1cae518ad350d517717c4

The error message is now:

test.d(2): Error: cannot implicitly convert expression (opCall()) of type Foo to Foo
Comment 3 yebblies 2012-02-03 23:59:17 UTC
Compiles without error on D1 (1.072)

Give a forward reference error with D2 (2.058)

struct Foo {
    enum x = Foo();

    static Foo opCall() {
        return Foo.init;
    }
}

testx.d(5): Error: forward reference to type Foo
testx.d(5): Error: cannot implicitly convert expression (Foo()) of type Foo to Foo
Comment 4 hsteoh 2014-08-06 14:55:33 UTC
Seems to work now (compiles and runs with -main), though it does hit a deprecation warning:
-----
test.d(2): Deprecation: variable test.Foo.x const field with initializer should be static, __gshared, or an enum
-----
Comment 5 hsteoh 2014-08-06 14:56:26 UTC
P.S. This is on git HEAD (post 2.066).
Comment 6 github-bugzilla 2014-08-10 12:54:36 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c43a17582bdfb7c28980803c05663a5d09526557
fix Issue 4225 - forward reference of opCall (mangle.c:81: char* mangle(Declaration*): Assertion `fd && fd->inferRetType' failed.)