Fix issues 9975 & 12479

https://issues.dlang.org/show_bug.cgi?id=9975
https://issues.dlang.org/show_bug.cgi?id=12479

See also: #1390