atom / language-c

C support in Atom
Other
118 stars 152 forks source link

Template Class Constructor Incorrect Highlighting #332

Closed BeefaloKing closed 5 years ago

BeefaloKing commented 5 years ago

Prerequisites

Description

Both the name and initializer list of template class constructors have incorrect syntax highlighting when defined outside the class declaration. image Edit: Added clarity in screenshot

Steps to Reproduce

  1. Define a constructor for a template class outside the class declaration
    
    template<typename T> class foo
    {
    public:
    foo();
    private:
    T *data;
    };

class bar { public: bar(); private: int *data; };

template foo::foo() : data(nullptr) {}

bar::bar() : data(nullptr) {}



### Versions

Atom    : 1.38.2
Electron: 2.0.18
Chrome  : 61.0.3163.100
Node    : 8.9.3

### Possible Related Issues

https://github.com/atom/language-c/issues/90
rsese commented 5 years ago

Thanks for the report! Noting I see the same thing as your screenshot in 1.40.0-nightly10 on macOS 10.12.6.

Both the name and initializer list of template class constructors have incorrect syntax highlighting when defined outside the class declaration.

Just so I'm on the same page, can you point to exactly where this is in your example?

BeefaloKing commented 5 years ago

The foo() and data(nullptr) on line 17. These should match the highlighting for the constructor bar() on line 20.

Additionally, if foo() were not a constructor, and had a return type, it would be highlighted correctly. (e.g. template<typename T> int foo<T>::foobar())

rsese commented 5 years ago

Heyo @maxbrunsfeld :wave:! We talked about this one today and think it might belong in https://github.com/tree-sitter/tree-sitter-cpp but were wondering if you could confirm?

maxbrunsfeld commented 5 years ago

think it might belong in https://github.com/tree-sitter/tree-sitter-cpp but were wondering if you could confirm?

Yup, you're right: we currently don't parse those template constructors correctly. Thanks!

BeefaloKing commented 5 years ago

Should I create a separate issue over there or is this (part of) an already known issue?

rsese commented 5 years ago

ahh sorry, missed your comment @BeefaloKing - I went ahead and copied over your issue so we'll close this in favor of that issue: https://github.com/tree-sitter/tree-sitter-cpp/issues/50.