Bug 7339 – [2.058] std.string.indexOf doesn't instantiate with inlining

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-01-21T12:08:00Z
Last change time
2012-01-24T12:34:40Z
Keywords
rejects-valid
Assigned to
nobody
Creator
dsimcha
Depends on
4724

Comments

Comment #0 by dsimcha — 2012-01-21T12:08:17Z
This is related to Bug 4724, but I'm filing it as a separate issue and labeling it a regression because something (probably the more aggressive inlining that was added for 2.058) expands the effects of that bug in ways that break previously working code. If we can't fix the compiler bug then we need to work around it to avoid an awful regression. import std.string; void main() { "".indexOf(""); } dmd -O -inline -release -c test.d /home/dsimcha/dmd2/linux/bin64/../../src/phobos/std/algorithm.d(2970): Error: function std.string.indexOf!(char,char).indexOf.simpleMindedFind!(__lambda6,const(char)[],const(char)[]).simpleMindedFind is a nested function and cannot be accessed from main Here's a reduced version that doesn't import any Phobos modules: void main() { "".indexOf("") ; } void indexOf(const(char)[] s, const(char)[] sub) { find!((dchar a, dchar b){return a == b;}) (s, sub); } void find(alias pred)(const(char)[] haystack, const(char)[] needle) { pred(haystack[0], needle[0]); } $ dmd -c -O -inline -release test.d test.d(11): Error: function test.indexOf.find!(delegate pure nothrow @safe bool(dchar a, dchar b) { return cast(uint)a == cast(uint)b; } ).find is a nested function and cannot be accessed from main
Comment #1 by clugdbug — 2012-01-24T12:34:40Z
*** This issue has been marked as a duplicate of issue 7199 ***