Summary: [2.058] std.string.indexOf doesn't instantiate with
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        Depends on: 4724

--- Comment #0 from David Simcha <> 2012-01-21 12:08:17 PST ---
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() {

dmd -O -inline -release -c test.d
/home/dsimcha/dmd2/linux/bin64/../../src/phobos/std/algorithm.d(2970): Error:
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

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

Reply via email to