[Issue 10212] Segfault in mismatching delegate literal types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu May 30 03:23:17 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=10212


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Segfault using wrong        |Segfault in mismatching
                   |delegate literal syntax,    |delegate literal types
                   |wrong error message         |


--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> 2013-05-30 03:23:15 PDT ---
(In reply to comment #0)
> int delegate() foo() {
>     return () => {
>         return 1;
>     };
> }

> Also the return type of foo is not int, it is int delegate().

It is not wrong delegate syntax.
The code is just equivalent with follows:

int delegate() foo() {
    return (){
        return (){    // L3
            return 1;
        };
    };
}

And reported error is changed to:
test.d(3): Error: mismatched function return type inference of int function()
pure nothrow @safe and int

The outer lambda should return int, because the lambda type should be deduced
to int delegate(). But it returns an inner lambda, which has the type "int
function() pure nothrow @safe". Then it conflicts with expected return type
"int". Reported error message is not wrong, too.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list