Bug 10212 – Segfault in mismatching delegate literal types
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-30T02:35:00Z
Last change time
2013-06-01T14:55:05Z
Keywords
ice, ice-on-invalid-code, pull
Assigned to
nobody
Creator
henning
Comments
Comment #0 by henning — 2013-05-30T02:35:29Z
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.
Comment #1 by henning — 2013-05-30T02:40:26Z
I know it's a bad time to come up with a regression :S
Comment #2 by ibuclaw — 2013-05-30T02:52:30Z
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()
Comment #3 by k.hara.pg — 2013-05-30T03:23:15Z
(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.