digitalmars.D.bugs - [Issue 14820] New: Templates not reevaluated inside static loop
- via Digitalmars-d-bugs (46/46) Jul 22 2015 https://issues.dlang.org/show_bug.cgi?id=14820
https://issues.dlang.org/show_bug.cgi?id=14820 Issue ID: 14820 Summary: Templates not reevaluated inside static loop unrolling Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: simendsjo gmail.com The summary text might be wrong as I'm not sure what the root cause is. The template is just evaluated on the first loop even though the underlying value changes: The following code: template TypeOf(alias T) { pragma(msg, "TypeOf evaluated with ", T.stringof); alias TypeOf = typeof(T); } void main() { import std.typetuple; foreach(type; TypeTuple!(int, short)) { type a; pragma(msg, "loop:") pragma(msg, " type: ", type); pragma(msg, " a: ", typeof(a)); alias t = TypeOf!a; pragma(msg, " TypeOf: ", t); } } Produces the following output: loop: type: int a: int TypeOf evaluated with a TypeOf: int loop: type: short a: short TypeOf: int Notice that the TypeOf template is only evaluated for the first pass through the loop. --
Jul 22 2015