Check C++ starter node comments against the C++ harness

未关闭
#594 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@bangyou0912 已经在做这个了。

开始于 2026年11月5日。

  • #595 来自 @bangyou0912 —— 未关闭

评估

这个 Issue 还没有评估数据。

描述

Follow-up to #344/#345, which tie the C starters' struct Node comment to the C harness. The C++ starters document ListNode, TreeNode and Node in a comment as well, while web/compiler-explorer.js declares the classes the code actually compiles against, and nothing compares the two copies, so a member renamed, a constructor dropped, or an initializer lost in one copy goes unnoticed.

One such drift is already on main. Three C++ starters (fraud-rule-worst-case, right-to-left-layout, staging-drift-check) document TreeNode(int x) : val(x), left(nullptr) {}, which leaves right indeterminate, while the harness constructor sets both children to nullptr. A candidate who reads the comment as the contract has to assume a leaf built with one argument carries a garbage right pointer, which is not what the code runs against.

A test in tests/browser/compiler-explorer.test.js could read the C++ harness's ListNode, TreeNode and Node declarations and, for every C++ starter that documents one of them, check that:

  • every documented member is declared by the harness with the same type;
  • every documented constructor has a harness constructor accepting the same parameter types;
  • every pointer member the matching harness constructor sets to null, the documented constructor initializes too.

Failures would name the page, the class and the member or constructor. I checked this by hand against the 36 starters (21 TreeNode, 11 ListNode, 4 Node): members and constructor signatures all agree today, and the initializer check reports right for the three pages above. Fixing their entries in problem-bank/problems.json and regenerating the pages makes it pass.

I would like to work on this.

主要语言
Rust
星标
223
派生
148
平均合并
1 天 11 小时
30 天内合并 PR
224

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sysprog21/codetrial 的其他 Issue

查看 sysprog21/codetrial 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。