Jump to page: 1 2
Thread overview
[Issue 11220] New: Regression in master: XXX__lambda2 cannot access frame of function XXX
Oct 10, 2013
deadalnix
Oct 10, 2013
deadalnix
Oct 11, 2013
Kenji Hara
Oct 11, 2013
deadalnix
Oct 11, 2013
Walter Bright
Oct 11, 2013
Walter Bright
Oct 11, 2013
Walter Bright
Oct 11, 2013
Walter Bright
Oct 11, 2013
Kenji Hara
Oct 11, 2013
Walter Bright
Oct 11, 2013
deadalnix
Oct 11, 2013
Kenji Hara
Oct 11, 2013
deadalnix
Oct 11, 2013
Walter Bright
Oct 19, 2013
deadalnix
Oct 19, 2013
deadalnix
October 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220

           Summary: Regression in master: XXX__lambda2 cannot access frame
                    of function XXX
           Product: D
           Version: future
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: deadalnix@gmail.com


--- Comment #0 from deadalnix <deadalnix@gmail.com> 2013-10-10 12:23:42 PDT ---
auto lex(R)(R ) {
    struct Lexer {
        int t;

        @property
        auto front() {
            return t;
        }
    }

    auto lexer = Lexer();

    return lexer;
}

auto flattenMixin() {
    auto trange = lex('\0');
    trange.parsePrimaryExpression();
}

void parsePrimaryExpression(R)(R trange) {
    trange.parseAmbiguous!((parsed) {
        trange.front;
    });
}

typeof(handler(null)) parseAmbiguous(alias handler, R)(R trange) {
    return handler(trange.parsePrimaryExpression());
}

Trying to compile this with DMD from master gives
src/d/semantic/declaration.d(24): Error: function
declaration.parsePrimaryExpression!(Lexer).parsePrimaryExpression.__lambda2!(typeof(null)).__lambda2
cannot access frame of function
declaration.parsePrimaryExpression!(Lexer).parsePrimaryExpression

This used to compile (this is a reduction of actual code in SDC).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 10, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220


deadalnix <deadalnix@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-10 18:26:27 PDT ---
Slightly verified test case.
1. Remove UFCS in order to compile the code by using old compiler.
2. Add dummy return type 'int' to parsePrimaryExpression function.

Compilation succeeds until 2.059. but with 2.060 and later, it causes "cannot access frame of function" error.

auto lex(R)(R ) {
    struct Lexer {
        int t;
        @property
        auto front() { return t; }
    }
    auto lexer = Lexer();
    return lexer;
}

auto flattenMixin() {
    auto trange = lex('\0');
    parsePrimaryExpression(trange);
}

int parsePrimaryExpression(R)(R trange) {
    parseAmbiguous!(/*delegate*/(parsed) {
        trange.front;
    })(trange);
    return 1;
}

typeof(handler(null)) parseAmbiguous(alias handler, R)(R trange) {
    return handler(parsePrimaryExpression(trange));
}

void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220



--- Comment #2 from deadalnix <deadalnix@gmail.com> 2013-10-10 18:32:06 PDT ---
This is surprising because I'm working with 2.063.2 . I guess I'm somehow being lucky. It may be dependant on the compilation order or the way things are spread accross modules.

Anyway, this is quite a showstopper.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220



--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2013-10-10 20:05:50 PDT ---
Even smaller test case:

struct Lexer {
    int x;
}

int parsePrimaryExpression(Lexer trange) {
    parseAmbiguous!( (parsed){ trange.x += 1; } )(trange);
    return 1;
}

typeof(handler(null)) parseAmbiguous(alias handler)(Lexer trange) {
    return handler(parsePrimaryExpression(trange));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220



--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2013-10-10 20:39:04 PDT ---
And smaller still:

int parsePrimaryExpression(int x) {
    parseAmbiguous!( (parsed){ x += 1; } )();
    return 1;
}

typeof(handler(1)) parseAmbiguous(alias handler)() {
    return handler(parsePrimaryExpression(1));
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220



--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2013-10-10 20:41:53 PDT ---
The trouble is in the "typeof(handler(1))". The type is "void", but the compiler instantiates the template "handler" along the way, and "handler" needs a frame pointer, and doesn't have one, hence the error.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220



--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2013-10-10 21:29:11 PDT ---
If I write it this way:

int parsePrimaryExpression(int x) {
    parseAmbiguous!( (parsed){ x += 1; } )();
    return 1;
}

template parseAmbiguous(alias handler)
{
    typeof(handler(1))
    //void
    parseAmbiguous() {
        return handler(1);
    }
}

We can see that instantiating handler(1) outside the function parseAmbiguous()
is what causes the error, because it needs the frame of parseAmbiguous().

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid


--- Comment #7 from Kenji Hara <k.hara.pg@gmail.com> 2013-10-10 21:36:35 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2652

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 11, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11220



--- Comment #8 from Walter Bright <bugzilla@digitalmars.com> 2013-10-10 21:56:11 PDT ---
(In reply to comment #7)
> https://github.com/D-Programming-Language/dmd/pull/2652

It's sure a pleasure working with you, Kenji!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2