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

Aperta
#594 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@bangyou0912 ci sta già lavorando.

Dal 5/11/2026.

  • #595 di @bangyou0912 — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

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.

Lingua principale
Rust
Stelle
223
Fork
148
Merge medio
1g 11h
PR unite (30g)
224

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di sysprog21/codetrial

Tutte le issue di sysprog21/codetrial

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.