Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IntelliSense fails to deduce types of CRTP-based expression templates. #6183

Open
PiliLatiesa opened this issue Sep 22, 2020 · 7 comments
Open
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service parser Visual Studio Inherited from Visual Studio
Projects
Milestone

Comments

@PiliLatiesa
Copy link

Type: LanguageService

Describe the bug

  • OS and Version: Linux x86_64
  • VS Code Version: 1.49
  • C/C++ Extension Version: 1.0.1
  • Other extensions you installed (and if the issue persists after disabling them): None
  • Does this issue involve using SSH remote to run the extension on a remote machine?: No
  • A clear and concise description of what the bug is, including information about the workspace (i.e. is the workspace a single project or multiple projects, size of the project, etc).

(Also reported as DEVCOM-1192188)

The following piece of code causes IntelliSense to display red squiggles in the identified line, albeit it is perfectly valid C++. It seems that either the EDG compiler or IntelliSense has trouble in figuring out the type of u + v.

template <int dim, int rank, typename, typename>
class BinaryExpr;

template <typename T>
class BaseExpr {};

template <int dim, int rank, typename... TRest, template <int, int, typename...> typename T>
class BaseExpr<T<dim, rank, TRest...>>
{
public:
  template <typename... URest, template <int, int, typename...> typename U>
  BinaryExpr<dim, rank, T<dim, rank, TRest...>, U<dim, rank, URest...>>
  operator +(BaseExpr<U<dim, rank, URest...>> const &rhs) const noexcept
    { return {*this, rhs}; }
};

template <int d, int r, typename T, typename U>
class BinaryExpr : public BaseExpr<BinaryExpr<d, r, T, U>>
{
private:
  BaseExpr<T> const &lhs;
  BaseExpr<U> const &rhs;

public:
  BinaryExpr(BaseExpr<T> const &lhs_, BaseExpr<U> const &rhs_) noexcept :
    lhs(lhs_), rhs(rhs_) {}
};

template <int dim, int rank>
class Field : public BaseExpr<Field<dim, rank>> {};

template <typename T>
void grad(BaseExpr<T> const &) {}

int main()
{
Field<2, 2> u, v;

grad(u + v); // ERROR: no instance of overloaded function matches the specified type
}

Steps to reproduce

  1. Just copy and paste the code in a file. It is a IntelliSense-related problem, independent of c_cpp_properties.json.

Expected behavior

IntelliSense to deduce the type of u + v.

Logs
@sean-mcmanus
Copy link
Collaborator

Thanks for reporting this. Yes, our parser is shared with VS so we'll track the issue with the VS issue you filed at https://developercommunity.visualstudio.com/content/problem/1192188/intellisense-fails-to-deduce-types-of-crtp-based-e.html .

@sean-mcmanus sean-mcmanus added this to the Tracking milestone Sep 22, 2020
@sean-mcmanus sean-mcmanus added parser Visual Studio Inherited from Visual Studio labels Sep 22, 2020
@PiliLatiesa
Copy link
Author

Sadly, the VS team closed the bug without fixing.

Anyway, I would like to post a minimal reproducer mostly based on https://eel.is/c++draft/temp#arg.template-example-3

template <template <class, class...> class TT, class T1, class... Rest>
void f(TT<T1, Rest...> const &) {}

template <typename T1> struct A {};

int main()
{ 
  A<int> a;
  f(a);   // bogus "no instance of overloaded function 'f' matches the specified type"
}

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Feb 25, 2022

@PiliLatiesa The VS team did a big bulk closure of a lot of developer community bugs (they have some odd data retention policy which requires closing the bugs after some time). We haven't gotten around to refiling them yet. Users impacted could refile if they want. We've started filing new VS bugs internally instead of on the developer community site to avoid the bulk closure problem.

I'm looking into whether this issue is being tracked internally or not...

@sean-mcmanus
Copy link
Collaborator

I've created a new internal bug to track this (1489992).

@PiliLatiesa
Copy link
Author

The issue has been fixed upstream: DEVCOM-1192188

Any idea about when the fix will land on the extension?

Thanks

@bobbrow bobbrow modified the milestones: Tracking, 1.20.0 Jan 30, 2024
@bobbrow bobbrow added this to Triage in 1.20 via automation Jan 30, 2024
@bobbrow
Copy link
Member

bobbrow commented Jan 30, 2024

The fix was just barely committed to VS so it won't be in our 1.19 release because we are nearing release and aren't accepting major IntelliSense updates at this stage in the release cycle (the fix came with EDG's 6.6 release). Instead, it will make it into our 1.20 release.

@sean-mcmanus sean-mcmanus moved this from Triage to To do in 1.20 Feb 23, 2024
@sean-mcmanus sean-mcmanus moved this from To do to Done in 1.20 Mar 25, 2024
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Mar 25, 2024
@sean-mcmanus
Copy link
Collaborator

@PiliLatiesa Fixed with https://github.com/microsoft/vscode-cpptools/releases/tag/v1.20.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service parser Visual Studio Inherited from Visual Studio
Projects
1.20
Done
Development

No branches or pull requests

3 participants