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 #3105 - Compile-time error when mixing named argument with automatic indexing #3214

Merged
merged 1 commit into from
Dec 4, 2022

Conversation

rbrich
Copy link
Contributor

@rbrich rbrich commented Nov 30, 2022

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
Copy link
Contributor

vitaut commented Dec 4, 2022

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