Thread overview
[Issue 10810] New: wrong forward reference error when using return type deduction and a cyclic call flow
Aug 12, 2013
Henning Pohl
Aug 12, 2013
timon.gehr@gmx.ch
Aug 12, 2013
Henning Pohl
Aug 13, 2013
timon.gehr@gmx.ch
Aug 13, 2013
Henning Pohl
August 12, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10810

           Summary: wrong forward reference error when using return type
                    deduction and a cyclic call flow
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: henning@still-hidden.de


--- Comment #0 from Henning Pohl <henning@still-hidden.de> 2013-08-12 12:39:06 PDT ---
auto a() { b(); }
auto b() { a(); }

---
main.d(2): Error: forward reference to a
---

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


timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch


--- Comment #1 from timon.gehr@gmx.ch 2013-08-12 13:07:40 PDT ---
I think this is expected behaviour and this issue is an enhancement.

Exactly which additional cases do you want to make work?

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



--- Comment #2 from Henning Pohl <henning@still-hidden.de> 2013-08-12 16:44:06 PDT ---
What do you mean with "additional cases"? The return types of these functions don't depend on each other. The code should compile just like this does:

void a() { b(); }
void b() { a(); }

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



--- Comment #3 from timon.gehr@gmx.ch 2013-08-12 19:01:18 PDT ---
(In reply to comment #2)
> What do you mean with "additional cases"?

The D programs that compile after the fix that wouldn't have compiled before.

> The return types of these functions don't depend on each other.

Indeed, but in order to fix this issue, we need a computationally decidable notion of dependence of function return types.

Currently, this is quite conservative. Analysis of any function is suspended if a function call with unresolved return type is encountered, until this return type has been resolved.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor


--- Comment #4 from Henning Pohl <henning@still-hidden.de> 2013-08-12 19:20:42 PDT ---
> The D programs that compile after the fix that wouldn't have compiled before.

I just wondered what DMD would do when I throw this at it. Of course those return type depencies can get awfully complex and can involve tons of functions.

> Indeed, but in order to fix this issue, we need a computationally decidable notion of dependence of function return types.

And it will be hard to get this implemented. The current behavior is neither surprising nor dangerous. De facto no one will encounter this bug so I will lower the importance to minor.

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