skygragon / leetcode-cli-plugins

3rd party plugins for leetcode-cli
MIT License
140 stars 53 forks source link

Leetcode test --local plugin not extracting type correctly #20

Open minhoolee opened 6 years ago

minhoolee commented 6 years ago

Problem Summary

I recently tried to leetcode test locally using --local. I ran into an error when doing so, and traced the error to the std::decay datatype of the input and output objects. It appears that line 58 of the plugin is not extracting the type correctly (should be std::decay< vector<int> > but is std::decay<>). Manually changing to std::decay< vector<int> > allows .tmp.cpp.run.cpp to be compiled and run correctly.

[ERROR] .tmp.cpp.run.cpp: In function ‘int main()’:
[ERROR] .tmp.cpp.run.cpp:252:9: error: wrong number of template arguments (0, should be 1)
[ERROR]    decay<>::type p0 = {3,9,20,15,7};
[ERROR]          ^
[ERROR] In file included from /usr/include/c++/7/bits/move.h:54:0,
[ERROR]                  from /usr/include/c++/7/bits/stl_pair.h:59,
[ERROR]                  from /usr/include/c++/7/utility:70,
[ERROR]                  from /usr/include/c++/7/algorithm:60,
[ERROR]                  from .tmp.cpp.run.cpp:2:
[ERROR] /usr/include/c++/7/type_traits:2116:11: note: provided for ‘template<class _Tp> class std::decay’
[ERROR]      class decay
[ERROR]            ^~~~~
[ERROR] .tmp.cpp.run.cpp:252:17: error: expected initializer before ‘p0’
[ERROR]    decay<>::type p0 = {3,9,20,15,7};
[ERROR]                  ^~
[ERROR] .tmp.cpp.run.cpp:253:9: error: wrong number of template arguments (0, should be 1)
[ERROR]    decay<>::type p1 = {9,3,15,20,7};
[ERROR]          ^
[ERROR] In file included from /usr/include/c++/7/bits/move.h:54:0,
[ERROR]                  from /usr/include/c++/7/bits/stl_pair.h:59,
[ERROR]                  from /usr/include/c++/7/utility:70,
[ERROR]                  from /usr/include/c++/7/algorithm:60,
[ERROR]                  from .tmp.cpp.run.cpp:2:
[ERROR] /usr/include/c++/7/type_traits:2116:11: note: provided for ‘template<class _Tp> class std::decay’
[ERROR]      class decay
[ERROR]            ^~~~~
[ERROR] .tmp.cpp.run.cpp:253:17: error: expected initializer before ‘p1’
[ERROR]    decay<>::type p1 = {9,3,15,20,7};
[ERROR]                  ^~
[ERROR] .tmp.cpp.run.cpp:254:26: error: ‘p0’ was not declared in this scope
[ERROR]    auto res = s.buildTree(p0,p1);
[ERROR]                           ^~
[ERROR] .tmp.cpp.run.cpp:254:26: note: suggested alternative: ‘y0’
[ERROR]    auto res = s.buildTree(p0,p1);
[ERROR]                           ^~
[ERROR]                           y0
[ERROR] .tmp.cpp.run.cpp:254:29: error: ‘p1’ was not declared in this scope
[ERROR]    auto res = s.buildTree(p0,p1);
[ERROR]                              ^~
[ERROR] .tmp.cpp.run.cpp:254:29: note: suggested alternative: ‘y1’
[ERROR]    auto res = s.buildTree(p0,p1);
[ERROR]                              ^~
[ERROR]                              y1

How to reproduce

leetcode test 105.construct-binary-tree-from-preorder-and-inorder-traversal.cpp --local

Relevant files .tmp.cpp.run.cpp 105.construct-binary-tree-from-preorder-and-inorder-traversal.cpp

Environment

skygragon commented 5 years ago

@minhoolee can't reproduce this, but the missing type should be extracted from question cache, clear cache might give a help?