Bug 7808 – Nullable's alias this does not work with structs containing classes

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-04-01T22:18:00Z
Last change time
2015-06-09T05:15:01Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
issues.dlang

Comments

Comment #0 by issues.dlang — 2012-04-01T22:18:58Z
This code compiled just fine with 2.058 import std.typecons; void main() { auto s = Nullable!S(S(new C)); func(s); } class C { } struct S { C c; this(C c) { this.c = c; } } void func(S s) { } But it fails to compile with the latest dmd, giving the error q.d(6): Error: function q.func (S s) is not callable using argument types (Nullable!(S)) q.d(6): Error: cannot implicitly convert expression (s) of type Nullable!(S) to S It works if the member variable is an int or string. It works if the member variable is a struct type which does _not_ have a class as a member variable. But if the struct has a member variable which is a class, or it has a member variable which is a struct which has a member variable which is a class, then it fails. Nullable!S' alias this should convert it to an S when passed to func, but it doesn't when S contains a member variable which is a class - either directly or indirectly.
Comment #1 by k.hara.pg — 2012-04-02T04:02:48Z
Comment #2 by github-bugzilla — 2012-04-05T10:54:30Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b90543ea6d93aec7963004261e8fa749b0bdbf35 Merge pull request #857 from 9rnsr/fix7808 Issue 7808 - Nullable's alias this does not work with structs containing classes