[LyX/master] Fixup f96b99dc: thinko

Richard Kimberly Heck rikiheck at lyx.org
Fri Oct 2 13:46:30 UTC 2020


On 10/2/20 5:41 AM, Jean-Marc Lasgouttes wrote:
> commit a97b384b07d81ee33815fd4f0e8a19c8ab2f66ed
> Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
> Date:   Fri Oct 2 12:06:32 2020 +0200
>
>     Fixup f96b99dc: thinko
>     
>     Setting the res value and returning from the function at the same time
>     does not make sense. After reflection, it is the "return" that shall
>     go.
>     
>     No idea what effect it had.
> ---
>  src/mathed/MathData.cpp |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp
> index 90f41eb..a128520 100644
> --- a/src/mathed/MathData.cpp
> +++ b/src/mathed/MathData.cpp
> @@ -972,7 +972,7 @@ MathClass MathData::lastMathClass() const
>  	for (MathAtom const & at : *this) {
>  		MathClass mc = at->mathClass();
>  		if (mc != MC_UNKNOWN)
> -			return res = mc;
> +			res = mc;
>  	}
>  	return res;

This is actually fine. Assignment returns a reference to the thing on
the left, at least by default. That is why

    a = b =c

does what you expect.

See
https://stackoverflow.com/questions/15292892/what-is-return-type-of-assignment-operator

Still, I find that kind of statement a bit confusing.

Riki




More information about the lyx-devel mailing list