Skip to content

fix #3105 - Compile-time error when mixing named argument with automatic indexing - #3214

Merged
vitaut merged 1 commit into
fmtlib:masterfrom
rbrich:fix_compile_time_named_arg
Dec 4, 2022
Merged

vitaut merged 1 commit into
fmtlib:masterfrom
rbrich:fix_compile_time_named_arg

Conversation

@rbrich

@rbrich rbrich commented Nov 30, 2022

Copy link
Copy Markdown
Contributor

Fixes #3105

Looks like this is enough to fix the issue.

I compared the runtime checking with compile-time checking and adjusted the compile-time version to mirror the runtime one.

The runtime check is this (second function for named args):

    FMT_CONSTEXPR auto on_arg_id(int id) -> int {
      return parse_context.check_arg_id(id), id;
    }
    FMT_CONSTEXPR auto on_arg_id(basic_string_view<Char> id) -> int {
      int arg_id = context.arg_id(id);
      if (arg_id < 0) on_error("argument not found");
      return arg_id;
    }

It returns the arg index directly without running it through the check_arg_id, unlike the indexed arg check.

@vitaut

vitaut commented Dec 4, 2022

Copy link
Copy Markdown
Contributor

Thank you!

@rbrich
rbrich deleted the fix_compile_time_named_arg branch December 5, 2022 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile-time error when mixing named argument with automatic indexing

2 participants