|
From: Alan M. <ac...@mu...> - 2017-03-26 14:29:15
|
Hello, Ludwig.
Thanks for the bug report, and thanks even more for cutting it down to a
nice, small, easy to work with snippet.
On Mon, Feb 20, 2017 at 16:22:41 +0000, lu...@lu... wrote:
> Hello Alan,
> if you consider the below C++ code:
> // NotHighlighted is defined in another file.
> template<typename Baz>
> class Foo : public Bar<Baz> {
> std::vector<NotHighlighted> foo;
> }
> With `emacs -Q` I get the display as shown in the attached file
> template0.png. Note, the symbol "NotHighlighted" is not highlighted like
> the symbol "Baz".
This is actually correct. CC Mode doesn't know whether or not
"NotHighlighted" is a type or not; it could easily be a constant
integer. (Yes, I know that std::vector always takes a type, but this
goes into semantics more than CC Mode wants to).
> If I erase '>' and put it back (just after "NotHighlighted"), the font
> lock seems to be refreshed and this time the symbol "NotHighlighted" is
> highlighted (see template1.png).
Yes, this seems to be a bug. ;-) That sequence of operations shouldn't
cause the fontification of "NotHighlighted". I'm trying to track this
down at the moment.
CC Mode maintains a collection of "known types" for each buffer -
identifiers which are known from their contexts to be types. Somehow,
"NotHighlighted" has got into this collection. I will figure out soon
how and why.
> Note, if I add the following C++ line "class NotHighlighted;", it is
> correct (cf. template2.png).
When you do this, "NotHighlighted" becomes a "known type" and the
fontification is then correct.
> Can you tell me if is an expected behavior? I would expected the
> template argument to be colored in an homogeneous way across the code.
> template[12].png seem correct.
See above.
The more fundamental question is whether an ambiguous template argument
should be fontified as a type or not. Doing so will inevitably lead to
errors in places where the identifier actually isn't a type.
> Thanks for your time
Thank you again for the report! I'll be back in touch again when I've
made more progress.
> Ludwig
> version: GNU Emacs 26.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version
> 2.24.28) of 2017-02-13
--
Alan Mackenzie (Nuremberg, Germany).
|