Skip to content

[BUG] Missing escape of char literal in interpolation #861

Closed
@JohelEGP

Description

@JohelEGP

Title: Missing escape of char literal in UFCS in interpolation.

Minimal reproducer (https://cpp2.godbolt.org/z/r1f73EP85):

#include <ranges>
main: () = {
  using namespace std::views;
  s := "".std::string();
  _ = "((_ = s.split('\n'), 0))$";
}
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -I . main.cpp

Expected result: static_cast<void>(cpp2::to_string((static_cast<void>(CPP2_UFCS(split, std::move(s), '\n')), 0)));.

Actual result and error: static_cast<void>(cpp2::to_string((static_cast<void>(CPP2_UFCS(split, std::move(s), 'n')), 0)));.

Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

#line 1 "/app/example.cpp2"


//=== Cpp2 type definitions and function declarations ===========================

#line 1 "/app/example.cpp2"
#include <ranges>
auto main() -> int;

//=== Cpp2 function definitions =================================================

#line 1 "/app/example.cpp2"

#line 2 "/app/example.cpp2"
auto main() -> int{
  using namespace std::views;
  auto s {CPP2_UFCS_0(std::string, "")}; 
  static_cast<void>(cpp2::to_string((static_cast<void>(CPP2_UFCS(split, std::move(s), 'n')), 0)));
}
Output:
Program returned: 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions