cppfront
cppfront copied to clipboard
[FIX] Correct get_declaration_of not to skip first symbol
While looking for the symbol there is a loop that searches backward using normal iterators. The loop will never check symbols.cbegin() as it is excluded by i != symbols.cbegin()
condition.
That makes in the below code we will never find the fun
symbol
fun: (inout i : int) -> * const int = {
return i&;
}
main: () -> int = {
i := 42;
p := fun(i);
// ...
}
This change replaces normal iterators with std::reverse_iterator
.
I made small mistake that cause skipping one symbol while using std::reverse_iterator
fixed in last push.
Thanks! I applied the basic change as a separate commit to also rename the function.
Verified on my side on my tests - works!
I wondered why I had added a bool value. I just realized that I needed to look outside of the named function in another PR: https://github.com/hsutter/cppfront/pull/96 (I needed that to deduce the type of the symbol - it was needed to deduce if we deal with a pointer or not).
I will rebase other PRs and will see what need to be adjusted