Bug 12451 – Simple range mistake not caught by compiler

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2014-03-24T05:32:00Z
Last change time
2014-03-24T11:07:51Z
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2014-03-24T05:32:39Z
This code compiles: void main() { import std.algorithm: map, sum; int[][][] mat; mat.map!(map!sum); } While this is wrong code: void main() { import std.algorithm: map, sum; int[][] mat; mat.map!(map!sum); } But the mistake is caught by the linker instead of the dmd, dmd 2.066alpha: OPTLINK (R) for Win32 Release 8.00.15 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html test.obj(test) Error 42: Symbol Undefined _D3std9algorithm38__T9MapResultS18€ sumTAiZ€Š£6__ctorMFNaNbNcNf€ƒžS€ÀÕ
Comment #1 by monarchdodra — 2014-03-24T06:24:30Z
(In reply to comment #0) > But the mistake is caught by the linker instead of the dmd, dmd 2.066alpha: I'm getting a compile error on win32 head: std\algorithm.d(469): Error: template std.algorithm.sum cannot deduce function from argument types !()(int), candidates are: std\algorithm.d(1079): std.algorithm.sum(R)(R r) if (isInputRange!R && !isInfinite!R && is(typeof(r.front + r.front))) std\algorithm.d(1090): std.algorithm.sum(R, E)(R r, E seed) if (isInputRange!R && !isInfinite!R && is(typeof(seed = seed + r.front))) std\algorithm.d(503): Error: template std.algorithm.sum cannot deduce function from argument types !()(int), candidates are: std\algorithm.d(1079): std.algorithm.sum(R)(R r) if (isInputRange!R && !isInfinite!R && is(typeof(r.front + r.front))) std\algorithm.d(1090): std.algorithm.sum(R, E)(R r, E seed) if (isInputRange!R && !isInfinite!R && is(typeof(seed = seed + r.front))) std\algorithm.d(515): Error: template std.algorithm.sum cannot deduce function from argument types !()(int), candidates are: std\algorithm.d(1079): std.algorithm.sum(R)(R r) if (isInputRange!R && !isInfinite!R && is(typeof(r.front + r.front))) std\algorithm.d(1090): std.algorithm.sum(R, E)(R r, E seed) if (isInputRange!R && !isInfinite!R && is(typeof(seed = seed + r.front))) std\algorithm.d(416): Error: template instance std.algorithm.MapResult!(sum, int[]) error instantiating std\algorithm.d(469): instantiated from here: map!(int[]) std\algorithm.d(416): instantiated from here: MapResult!(map, int[][]) main.d(11): instantiated from here: map!(int[][])
Comment #2 by bearophile_hugs — 2014-03-24T11:07:51Z
(In reply to comment #1) > I'm getting a compile error on win32 head: > > std\algorithm.d(469): Error: template std.algorithm.sum cannot deduce function > from argument types !()(int), candidates are: > ... I have just updated and re-compiled my compiler and indeed the optlink error has being replaced by normal errors. Issue closed and sorry for the noise :-)