Thread overview
[Issue 10810] wrong forward reference error when using return type deduction and a cyclic call flow
May 24, 2014
Stewart Gordon
Jul 02, 2017
Vladimir Panteleev
Jul 02, 2017
timon.gehr@gmx.ch
Jul 03, 2017
Vladimir Panteleev
Jul 03, 2017
timon.gehr@gmx.ch
Jul 03, 2017
Vladimir Panteleev
Nov 24, 2020
Vladimir Panteleev
Dec 17, 2022
Iain Buclaw
Jan 04, 2023
RazvanN
May 24, 2014
https://issues.dlang.org/show_bug.cgi?id=10810

Stewart Gordon <smjg@iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |smjg@iname.com

--
July 02, 2017
https://issues.dlang.org/show_bug.cgi?id=10810

--- Comment #5 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to timon.gehr from comment #3)
> 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.

Short-circuiting return type analysis to "void" if there are no return statements in the body seems like a reasonable way to solve this particular case to me.

--
July 02, 2017
https://issues.dlang.org/show_bug.cgi?id=10810

--- Comment #6 from timon.gehr@gmx.ch ---
(In reply to Vladimir Panteleev from comment #5)
> (In reply to timon.gehr from comment #3)
> > 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.
> 
> Short-circuiting return type analysis to "void" if there are no return statements in the body seems like a reasonable way to solve this particular case to me.

The compiler does not know whether there are any return statements in the body when starting the analysis of a function because of conditional compilation and string mixins.

--
July 03, 2017
https://issues.dlang.org/show_bug.cgi?id=10810

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dlang-bugzilla@thecybershad
                   |                            |ow.net

--- Comment #7 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to timon.gehr from comment #6)
> The compiler does not know whether there are any return statements in the body when starting the analysis of a function because of conditional compilation and string mixins.

Are you saying that the compiler knows that a calls b, but doesn't know that a doesn't have any return statements?

--
July 03, 2017
https://issues.dlang.org/show_bug.cgi?id=10810

--- Comment #8 from timon.gehr@gmx.ch ---
(In reply to Vladimir Panteleev from comment #7)
> (In reply to timon.gehr from comment #6)
> > The compiler does not know whether there are any return statements in the body when starting the analysis of a function because of conditional compilation and string mixins.
> 
> Are you saying that the compiler knows that a calls b, but doesn't know that a doesn't have any return statements?

What I'm saying is that you cannot short-circuit semantic analysis of function bodies based on unknown information. How would the compiler determine that there are no return statements in a's body?

E.g.:

auto a(){ auto y = b(); mixin(foo(y)); } // whether a returns depends on the
return type of b.

--
July 03, 2017
https://issues.dlang.org/show_bug.cgi?id=10810

--- Comment #9 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to timon.gehr from comment #8)
> What I'm saying is that you cannot short-circuit semantic analysis of function bodies based on unknown information. How would the compiler determine that there are no return statements in a's body?

In the general case, yes. I was talking about this particular case, as I've said above.

--
November 24, 2020
https://issues.dlang.org/show_bug.cgi?id=10810

--- Comment #10 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to timon.gehr from comment #6)
> The compiler does not know whether there are any return statements in the body when starting the analysis of a function because of conditional compilation and string mixins.

Um, does the compiler reuse this information across instantiations of the same function template with different template parameters? See issue 21419.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=10810

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--
January 04, 2023
https://issues.dlang.org/show_bug.cgi?id=10810

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #11 from RazvanN <razvan.nitu1305@gmail.com> ---
I would vote to close this as a WONTFIX. Yeah, this simple case could be fixed by adding a special case, but as Timon mentioned it's really hard to correctly implement the general case.

--