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.
Comment #4 by k.hara.pg — 2013-05-30T03:33:00Z
Comment #5 by github-bugzilla — 2013-06-01T14:15:15Z
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
Comment #6 by github-bugzilla — 2013-06-01T14:55:05Z
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