Thread overview
[Issue 10212] New: Segfault using wrong delegate literal syntax, wrong error message
May 30, 2013
Henning Pohl
May 30, 2013
Henning Pohl
May 30, 2013
Iain Buclaw
[Issue 10212] Segfault in mismatching delegate literal types
May 30, 2013
Kenji Hara
May 30, 2013
Kenji Hara
Jun 01, 2013
Henning Pohl
May 30, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10212

           Summary: Segfault using wrong delegate literal syntax, wrong
                    error message
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: henning@still-hidden.de


--- Comment #0 from Henning Pohl <henning@still-hidden.de> 2013-05-30 02:35:29 PDT ---
int delegate() foo() {
    return () => {
        return 1;
    };
}

void main() {
}

-----
main.d(2): Error: mismatched function return type inference of int function()
pure nothrow @safe and int
Segmentation fault (core dumped)
-----

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

Doesn't segfault using GDC/LDC 2.060 on dpaste.

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



--- Comment #1 from Henning Pohl <henning@still-hidden.de> 2013-05-30 02:40:26 PDT ---
I know it's a bad time to come up with a regression :S

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


Iain Buclaw <ibuclaw@ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw@ubuntu.com


--- Comment #2 from Iain Buclaw <ibuclaw@ubuntu.com> 2013-05-30 02:52:30 PDT ---
Note:  is a front-end bug so is present in current gdc development.

Backtrace:

0x5e7a18 Type::covariant(Type*, unsigned long*)
0x5795c9 FuncExp::castTo(Scope*, Type*)
0x5bf988 FuncDeclaration::semantic3(Scope*)
0x59d8f6 FuncExp::semantic(Scope*)
0x60f74a ReturnStatement::semantic(Scope*)
0x610b8c CompoundStatement::semantic(Scope*)
0x5bf8bb FuncDeclaration::semantic3(Scope*)
0x5f2307 Module::semantic3()

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


Kenji Hara <k.hara.pg@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@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: -------
May 30, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10212


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2013-05-30 03:33:00 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2101

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



--- Comment #5 from github-bugzilla@puremagic.com 2013-06-01 14:15:15 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e1ac707489c96bbc6bfd78e584d1c0665b6136fa fix Issue 10212 - Segfault in mismatching delegate literal types

https://github.com/D-Programming-Language/dmd/commit/3a436b8177f931e2230695da095599bf69966d1a Merge pull request #2101 from 9rnsr/fix10212

[REG2.061] Issue 10212 - Segfault in mismatching delegate literal types

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


Henning Pohl <henning@still-hidden.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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



--- Comment #6 from github-bugzilla@puremagic.com 2013-06-01 14:55:05 PDT ---
Commit pushed to 2.063 at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/47260a9a67112d55698ff6bb1a374cd7bc44d500 Merge pull request #2101 from 9rnsr/fix10212

[REG2.061] Issue 10212 - Segfault in mismatching delegate literal types

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