Bug 4724 – Template literal escaping: Inconsistent behavior when -inline is on

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-08-25T08:31:00Z
Last change time
2012-01-24T13:41:42Z
Assigned to
nobody
Creator
dsimcha
Blocks
7339

Comments

Comment #0 by dsimcha — 2010-08-25T08:31:42Z
Not sure if this is a rejects-valid or an accepts-invalid, since the spec isn't clear on how passing template alias parameters that refer to a function scope is supposed to work. The inconsistency, though, means at least one of these is wrong. import std.algorithm, std.array; void main() { uint[] arr = [1, 2, 3]; // Doesn't work with -inline auto res1 = array( map!((a) { return a == arr[0]; })(arr) ); // Works if the previous statement is commented out or -inline // is disabled. auto res2 = array( map!((uint a) { return a == arr[0]; })(arr) ); } Error message (version 2.048, only when -inline is enabled): test.d(8): Error: function D main is a nested function and cannot be accessed from array
Comment #1 by bearophile_hugs — 2011-09-22T14:19:41Z
This is an important issue, I hit it often.
Comment #2 by dsimcha — 2012-01-24T13:41:42Z
*** This issue has been marked as a duplicate of issue 4841 ***