Bug 17299 – [Reg 2.071] Compile failure only on -de

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-04-06T18:27:16Z
Last change time
2018-12-24T13:49:54Z
Keywords
industry
Assigned to
No Owner
Creator
Johan Engelen

Comments

Comment #0 by jbc.engelen — 2017-04-06T18:27:16Z
The following code fragment compiles without any output with `-d` and `-dw` but errors with `-de`: file std/aaa.d ``` @nogc void toLower(dchar) { } ``` file str.d ``` module std.str; char front(T)(T) { return 'a'; } char back(T)(T) { return 'a'; } ptrdiff_t lastIndexOf(T)(const(T), dchar){ import std.aaa; return 1; } bool endsWith(alias pred, R1, R2)(R1 doesThisEnd, R2 withThis) if (is(typeof(pred(doesThisEnd.back, withThis)))) { return false; } ptrdiff_t lastIndexOf(Char1, Char2)(const(Char1)[] s, const(Char2)[] sub) { return lastIndexOf(s, sub.front); if (endsWith!((a, b) => std.aaa.toLower(a))(s, sub)) return 1; } void foo(string src) { src.lastIndexOf("_"); } ``` Commandline is `dmd -c -o- -de str.d` and errors with ``` str.d(30): Error: template std.str.endsWith cannot deduce function from argument types !((a, b) => std.aaa.toLower(a))(const(char)[], const(char)[]), candidates are: str.d(20): std.str.endsWith(alias pred, R1, R2)(R1 doesThisEnd, R2 withThis) if (is(typeof(pred(doesThisEnd.back, withThis)))) str.d(36): Error: template instance std.str.lastIndexOf!(char, char) error instantiating ``` Compiles without issues with dmd 2.070.2 Perhaps duplicated/related to https://issues.dlang.org/show_bug.cgi?id=9960
Comment #1 by bugzilla — 2017-04-11T08:46:04Z
What's happening is that std.aaa is imported only within the function lastIndexOf(const(T), dchar), yet is referred to in lastIndexOf(const(Char1)[] s, const(Char2)[] sub). At a minimum, this is a bug in the example.
Comment #2 by bugzilla — 2017-04-11T09:05:53Z
Considerably simplified as: file sss/aaa.d ``` void toLower() { } ``` file test.d ``` module sss.str; void bar(){ import sss.aaa; } void endsWith(alias pred)() if (is(typeof(pred('a')))) { } void lastIndexOf() { endsWith!((a) => sss.aaa.toLower())(); } ```
Comment #3 by razvan.nitu1305 — 2018-12-24T13:05:33Z
I cannot reproduce this. Close as invalid?
Comment #4 by johanengelen — 2018-12-24T13:49:54Z
Yep, seems to have been fixed in the meantime.