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

Fix print check for object that return different types for begin() and end() #517

Closed
1 task done
lackhole opened this issue Jan 21, 2024 · 1 comment
Closed
1 task done
Assignees
Labels

Comments

@lackhole
Copy link
Contributor

lackhole commented Jan 21, 2024

  • Checked for duplicates

Describe the bug

A range object that return different types for begin() and end() fails to check if the types is printable.

Expected behavior

printValue_impl<CollectionType> must not fail whether CollectionType is printable or not.

To Reproduce

I'm using C++14 library that provide vccc::views::iota that models std::views::iota.
The standard defines that It returns different type for sentinel if it models unbounded iota_view.

Anyway, detailed description is not really necessary because the fix is really simple and intuitive.

Input line

vccc::views::iota(10) | vccc::views::take(4)

Output

In file included from input_line_11:1:
In file included from /Users/yonggyulee/Documents/GitHub/lackhole/xeus-cling/install/include/xcpp/xmime.hpp:16:
/usr/local/include/cling/Interpreter/RuntimePrintValue.h:224:7: error: 'auto' deduced as 'counted_iterator<I>' (aka 'counted_iterator<vccc::ranges::iota_view<int, vccc::unreachable_sentinel_t>::iterator>') in declaration of 'iter' and deduced as 'sentinel<true>' in declaration of 'iterEnd'
      auto iter = obj->begin(), iterEnd = obj->end();
      ^           ~~~~~~~~~~~~            ~~~~~~~~~~
/usr/local/include/cling/Interpreter/RuntimePrintValue.h:241:39: note: in instantiation of function template specialization 'cling::collectionPrinterInternal::printValue_impl<vccc::ranges::take_view<vccc::ranges::iota_view<int>>>' requested here
    return collectionPrinterInternal::printValue_impl(obj);
                                      ^
/Users/yonggyulee/Documents/GitHub/lackhole/xeus-cling/install/include/xcpp/xmime.hpp:49:39: note: in instantiation of function template specialization 'cling::printValue<vccc::ranges::take_view<vccc::ranges::iota_view<int>>>' requested here
        bundle["text/plain"] = cling::printValue(&value);
                                      ^
input_line_24:2:2: note: in instantiation of function template specialization 'xcpp::mime_bundle_repr<vccc::ranges::take_view<vccc::ranges::iota_view<int>>>' requested here
 mime_bundle_repr(*(*(vccc::ranges::take_view<vccc::ranges::iota_view<int, vccc::unreachable_sentinel_t>>**)0x7ff7b1808090));

Setup

  1. Cling version: master
  2. Operating system: macOS 14.0
  3. How you obtained Cling: Build from source

Fix

Just Change the following lines
https://github.com/root-project/cling/blob/master/include/cling/Interpreter/RuntimePrintValue.h#L203
https://github.com/root-project/cling/blob/master/include/cling/Interpreter/RuntimePrintValue.h#L224

auto iter = obj->begin(), iterEnd = obj->end();

To

auto iter = obj->begin(); 
auto iterEnd = obj->end();

Created a PR #516

After fix

image

@ferdymercury
Copy link
Contributor

Closing here as it has been moved to ROOT repo: root-project/root#14966

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants