diff --git a/include/fmt/compile.h b/include/fmt/compile.h index 30ee85df..39b8969c 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -668,11 +668,8 @@ constexpr auto compile_format_string(S format_str) { format_str); } } else if constexpr (arg_id_result.arg_id.kind == arg_id_kind::name) { - static_assert( - ID != manual_indexing_id, - "cannot switch from manual to automatic argument indexing"); if constexpr (c == '}') { - return parse_tail( + return parse_tail( runtime_named_field{arg_id_result.arg_id.val.name}, format_str); } else if constexpr (c == ':') { diff --git a/test/compile-test.cc b/test/compile-test.cc index ce23c2f5..ed34429d 100644 --- a/test/compile-test.cc +++ b/test/compile-test.cc @@ -262,18 +262,14 @@ TEST(CompileTest, Named) { EXPECT_EQ("foobar", fmt::format(FMT_COMPILE("{a0}{a1}"), fmt::arg("a0", "foo"), fmt::arg("a1", "bar"))); - EXPECT_EQ("foobar", - fmt::format(/*FMT_COMPILE(*/ "{}{a1}" /*)*/, fmt::arg("a0", "foo"), - fmt::arg("a1", "bar"))); - EXPECT_EQ("foofoo", - fmt::format(/*FMT_COMPILE(*/ "{a0}{}" /*)*/, fmt::arg("a0", "foo"), - fmt::arg("a1", "bar"))); - EXPECT_EQ("foobar", - fmt::format(/*FMT_COMPILE(*/ "{a0}{1}" /*)*/, fmt::arg("a0", "foo"), - fmt::arg("a1", "bar"))); - EXPECT_EQ("foobar", - fmt::format(/*FMT_COMPILE(*/ "{0}{a1}" /*)*/, fmt::arg("a0", "foo"), - fmt::arg("a1", "bar"))); + EXPECT_EQ("foobar", fmt::format(FMT_COMPILE("{}{a1}"), fmt::arg("a0", "foo"), + fmt::arg("a1", "bar"))); + EXPECT_EQ("foofoo", fmt::format(FMT_COMPILE("{a0}{}"), fmt::arg("a0", "foo"), + fmt::arg("a1", "bar"))); + EXPECT_EQ("foobar", fmt::format(FMT_COMPILE("{0}{a1}"), fmt::arg("a0", "foo"), + fmt::arg("a1", "bar"))); + EXPECT_EQ("foobar", fmt::format(FMT_COMPILE("{a0}{1}"), fmt::arg("a0", "foo"), + fmt::arg("a1", "bar"))); EXPECT_EQ("foobar", fmt::format(FMT_COMPILE("{}{a1}"), "foo", fmt::arg("a1", "bar")));