<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/89898>89898</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Ranges pipe syntax broken after commit #c1086532d4d5 when using std module.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
stripe2933
</td>
</tr>
</table>
<pre>
The following code
```cpp
#include <print>
#include <ranges>
int main(){
using namespace std::string_view_literals;
std::println("{}", "abcde"sv | std::views::transform([](char c) { return c - 'a'; }));
}
```
works correctly ([godbolt link](https://godbolt.org/z/T4vYssK8z)) in Clang trunk. However, when changing the header inclusion to `import std;`, then the code will emit error:
```
main.cpp:5:34: error: invalid operands to binary expression ('basic_string_view<char>' and '__range_adaptor_closure_t<__bind_back_t<__fn, tuple<(lambda at main.cpp:5:58)>>>' (aka 'std::__1::ranges::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__transform::__fn, std::__1::tuple<(lambda at main.cpp:5:58)>>>'))
5 | std::println("{}", "abcde"sv | std::views::transform([](char c) { return c - 'a'; }));
| ~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
llvm-project/build/include/c++/v1/cstddef:73:45: note: candidate function not viable: no known conversion from 'basic_string_view<char>' to 'byte' for 1st argument
73 | _LIBCPP_HIDE_FROM_ABI inline constexpr byte operator|(byte __lhs, byte __rhs) noexcept {
| ^ ~~~~~~~~~~
llvm-project/build/include/c++/v1/__charconv/chars_format.h:34:53: note: candidate function not viable: no known conversion from 'basic_string_view<char>' to 'chars_format' for 1st argument
34 | inline _LIBCPP_HIDE_FROM_ABI constexpr chars_format operator|(chars_format __x, chars_format __y) {
| ^ ~~~~~~~~~~~~~~~~
llvm-project/build/include/c++/v1/future:433:55: note: candidate function not viable: no known conversion from 'basic_string_view<char>' to 'launch' for 1st argument
433 | inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR launch operator|(launch __x, launch __y) {
| ^ ~~~~~~~~~~
llvm-project/build/include/c++/v1/bitset:929:1: note: candidate template ignored: could not match 'bitset' against 'basic_string_view'
929 | operator|(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT {
| ^
llvm-project/build/include/c++/v1/valarray:2858:1: note: candidate template ignored: requirement '__is_val_expr<std::__1::basic_string_view<char, std::__1::char_traits<char>>>::value' was not satisfied [with _Expr1 = basic_string_view<char>, _Expr2 = __range_adaptor_closure_t<__bind_back_t<__fn, tuple<(lambda at main.cpp:5:58)>>>]
2858 | operator|(const _Expr1& __x, const _Expr2& __y) {
| ^
llvm-project/build/include/c++/v1/valarray:2867:5: note: candidate template ignored: requirement '__is_val_expr<std::__1::basic_string_view<char, std::__1::char_traits<char>>>::value' was not satisfied [with _Expr = basic_string_view<char>]
2867 | operator|(const _Expr& __x, const typename _Expr::value_type& __y) {
| ^
llvm-project/build/include/c++/v1/valarray:2876:5: note: candidate template ignored: requirement '__is_val_expr<std::__1::ranges::__range_adaptor_closure_t<std::__bind_back_t<std::__1::ranges::views::__transform::__fn, std::__1::tuple<(lambda at main.cpp:5:58)>>>>::value' was not satisfied [with _Expr = __range_adaptor_closure_t<__bind_back_t<__fn, tuple<(lambda at main.cpp:5:58)>>>]
2876 | operator|(const typename _Expr::value_type& __x, const _Expr& __y) {
| ^
1 error generated.
```
Compiler: Clang 18.1.4, Libc++: trunk.
I followed the standard library module instruction documented in [libc++ document](https://libcxx.llvm.org/Modules.html#using-in-external-projects).
I noticed that the commits before `c1086532d4d5`, which corresponds to the PR #89148 does not print this error. It seems that the PR is problem.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcWE1v4zgS_TX0pdCGTUqWdfDBcWJMY2emg0wfZk8CJZYtbihSS1J20of97QtSsuO4HfdOsBMMRhBs8bv43it-FHdObjXigqQ3JL0d8c7Xxi6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