Bug 4842 – Wrong code with template literals

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-09-08T20:02:00Z
Last change time
2011-08-12T20:45:54Z
Keywords
wrong-code
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2010-09-08T20:02:38Z
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() { writeln(factors(36)); } If I change the line with the lambda from a template literal to a delegate literal: return filter!((I i) { return num % i == 0; }) then it works.
Comment #1 by dsimcha — 2011-08-12T20:45:54Z
Can't reproduce this anymore.