Skip to content

fix: 收紧 streamable fallback jsonization<T> 的 requires#12

Open
weinibuliu wants to merge 1 commit intomasterfrom
fix/serialization/cv-point
Open

fix: 收紧 streamable fallback jsonization<T> 的 requires#12
weinibuliu wants to merge 1 commit intomasterfrom
fix/serialization/cv-point

Conversation

@weinibuliu
Copy link
Member

@weinibuliu weinibuliu commented Mar 20, 2026

Summary by Sourcery

Bug Fixes:

  • 当类型 T 已经匹配内建的 JSON 值、数组、对象,或经工具检测为集合/元组/map/可空类型/variant 等类别时,避免为可流式输出类型选择 jsonization<T>
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Prevent jsonization for streamable types from being selected when T already matches built-in JSON value, array, object, or utility-detected collection/tuple/map/nullable/variant categories.

@weinibuliu weinibuliu requested review from MistEO and neko-para March 20, 2026 05:41
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些总体反馈:

  • 由于这个回退逻辑现在依赖多个 json::_utils 类型萃取(type traits),建议提取出一个具名 concept(例如 streamable_non_json_type),以便集中约束逻辑,并在这些 traits 在其他地方发生变化时,降低行为不一致的风险。
  • 在公共头文件中使用内部的 json::_utils traits 会加深对实现细节的耦合;如果可能的话,更推荐使用对外公开的 traits,或者包一层薄的 concept 封装,从而避免在 API 表面暴露内部的辅助工具。
面向 AI Agents 的提示
Please address the comments from this code review:

## Overall Comments
- Since this fallback now depends on multiple json::_utils type traits, consider extracting a named concept (e.g., `streamable_non_json_type`) to centralize the constraint logic and reduce the risk of divergence if these traits change elsewhere.
- Using internal `json::_utils` traits in a public header can tighten coupling to implementation details; if possible, prefer public-facing traits or a thin wrapper concept to avoid exposing internal helpers in the API surface.

Sourcery 对开源项目免费——如果你觉得我们的代码审查有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈改进之后的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • Since this fallback now depends on multiple json::_utils type traits, consider extracting a named concept (e.g., streamable_non_json_type) to centralize the constraint logic and reduce the risk of divergence if these traits change elsewhere.
  • Using internal json::_utils traits in a public header can tighten coupling to implementation details; if possible, prefer public-facing traits or a thin wrapper concept to avoid exposing internal helpers in the API surface.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since this fallback now depends on multiple json::_utils type traits, consider extracting a named concept (e.g., `streamable_non_json_type`) to centralize the constraint logic and reduce the risk of divergence if these traits change elsewhere.
- Using internal `json::_utils` traits in a public header can tighten coupling to implementation details; if possible, prefer public-facing traits or a thin wrapper concept to avoid exposing internal helpers in the API surface.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


template <has_output_operator T>
requires(!std::is_constructible_v<json::value, T> && !std::is_constructible_v<json::array, T> && !std::is_constructible_v<json::object, T>)
requires(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按理说应该能命中is_constructible_v<json::array, T>吧, 先看看为啥没命中?

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.

3 participants