Skip to content

fix: resolve recursive alias error in Value formatter#1

Open
tonytranrp wants to merge 1 commit intoEclipseMenu:mainfrom
tonytranrp:main
Open

fix: resolve recursive alias error in Value formatter#1
tonytranrp wants to merge 1 commit intoEclipseMenu:mainfrom
tonytranrp:main

Conversation

@tonytranrp
Copy link

@tonytranrp tonytranrp commented Feb 6, 2026

From: Azalea Client Contributors
Subject: [PATCH] Fix MSVC C2968 recursive alias declaration error with fmt formatter

Description

Problem

When compiling with MSVC (tested with VS2022 v17.x) and fmt v11.x, the fmt::formatter<rift::Value> specialization fails to compile with error C2968: 'mapped_type_constant<rift::Value,fmt::v11::context>': recursive alias declaration

This occurs because rift::Value is a recursive type (contains Array and Object which hold Values), and the formatter's use of fmt::join() and nested fmt::format_to() triggers fmt's type mapping system during formatter instantiation.

Solution

Replace fmt::join() and nested value formatting with a private helper method that manually iterates and formats elements. This avoids triggering fmt's mapped_type_constant machinery while the formatter is being instantiated.

Changes

  • Add private format_value() helper template method
  • Remove use of fmt::join() for arrays
  • Manually iterate arrays and objects with explicit recursive calls
  • Fix bug where object iteration index was never incremented

Testing

  • Tested with MSVC 19.40+ (VS2022)
  • Tested with fmt 11.0.2
  • Tested with fmt 10.2.1 (backwards compatible)

Related

  • Affects Windows/MSVC users
  • GCC and Clang may not exhibit this issue due to different template instantiation order

Introduce a private helper function to handle formatting of nested Value
types. This change prevents MSVC C2968 "recursive alias declaration"
errors caused by recursive type mapping when using fmt::join or direct
formatting of nested containers.
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.

1 participant