On Monday, 8 April 2019 at 07:53:23 UTC, Robert M. Münch wrote:
On 2019-04-07 19:28:02 +0000, Dennis said:
Did you import it? import std.algorithm;
:-/ of course not...
Why does DMD not give a hint, that an import from the standard
lib might be missing?
It does do this, so the question should be: why aren't its
warnings
more extensive?
Example:
void main() {
writeln("Hello, world!");
}
Fails to compile with this error:
./missing.d(4): Error: writeln is not defined, perhaps import
std.stdio; is needed?
That seems to come from src/dmd/expressionsem.d , which uses
importHint from
src/dmd/imphint.d , which just has this list:
shared static this()
{
// in alphabetic order
hints = [
"calloc": "core.stdc.stdlib",
"cos": "std.math",
"fabs": "std.math",
"free": "core.stdc.stdlib",
"malloc": "core.stdc.stdlib",
"printf": "core.stdc.stdio",
"realloc": "core.stdc.stdlib",
"sin": "std.math",
"sqrt": "std.math",
"writefln": "std.stdio",
"writeln": "std.stdio",
"__va_argsave_t": "core.stdc.stdarg",
"__va_list_tag": "core.stdc.stdarg",
];
}