|
From: Lud <lu...@lu...> - 2017-03-28 07:08:51
|
Alan,
> 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.
Let me know when I can help for testing.
> 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.
I think it is better to not font lock ambiguous template arguments,
because of the following reasons:
1. correctness - as you said, "errors [...] where the identifier
actually isn't a type"
2. less font lock is a speedup to render the source file because it is a
heavy process which can be annoying for large files.
Ludwig
On 03/26/2017 03:28 PM, Alan Mackenzie wrote:
> 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
>
|