Summary: Wrong code with template literals
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD

--- Comment #0 from David Simcha <> 2010-09-08 20:02:38 PDT ---
The following code was written for Rosetta Code and is intended to find all
factors of an integer.  It produces wrong results.  The exact wrong results
depend on whether inlining is enabled.

import std.range, std.algorithm, std.stdio;

auto factors(I)(I num) {
    return filter!((i) { return num % i == 0; })(
        iota(1, num + 1)

void main() {

If I change the line with the lambda from a template literal to a delegate

return filter!((I i) { return num % i == 0; })

then it works.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to