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

オープン
#594 コメント 0 件 リアクション 0 件 担当者 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時間
マージ済み PR(30日)
224

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sysprog21/codetrial のほかの issue

sysprog21/codetrial の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。