det translator: --style structured writes invalid Java for a digit-first COBOL name (ZECS001 50702-MESSAGE)

オープン
#7,375 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
63/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, python
領域
compilers

調査の方向性

Start in gitgalaxy/tools/cobol_to_java/det/gen.py around line 161, where the structured path calls camel(it.name) without the digit prefix that the dispatch path applies. Compare the two paths, then check the other camel() callers, including the paragraph one near line 911. Reproduce with the digit-first 50702-MESSAGE example through det.program.translate in structured style. Done when the structured output for that name is a legal Java identifier and a new test that parses or compiles it passes.

索引モデルが issue の本文から書いたものです。

説明

bug legacy-modernization priority: high scope:core

What happens. With style="structured", the det translator writes invalid Java for a COBOL data item whose name starts with a digit.

Reproduced on main f842015da with det.program.translate:

       01  50702-MESSAGE.
           02  50702-KEY PIC X(08) VALUE 'xxxxxxxx'.

dispatch keeps its s_50702_MESSAGE names and is clean. structured, typed or not, declares a Java field whose name starts with a digit, which does not compile. Real case: zECS ZECS001.cbl:288 (01 50702-MESSAGE) gives private final Field 50702Message.

Cause. gitgalaxy/tools/cobol_to_java/det/gen.py:161 (base = camel(it.name) ..., in the structured path) uses camel() as is. Its docstring says "callers prefix a digit", and this caller does not.

Who it reaches. tests/tools/det_port.py defaults to --style dispatch, so committed det ports and proofs are not affected. gitgalaxy/tools/cobol_to_java/port_runner.py:653 defaults to structured, so a user's det run through port_runner does reach it. COBOL allows digit-first names, so any estate can hit this.

Found by the cobolrt API contract work: tests/tools/cobolrt_api.py --check --generated exits 1 on a structured work directory. That scan is manual today (#7356).

Fix. Prefix the name at this caller the way the dispatch path does, then check every other camel() caller for the same gap. Add a test that translates a digit-first name in structured style and parses or compiles the result.

Note. This edits gitgalaxy/tools/cobol_to_java/** (GENERATOR), so evidence records using gen.py go stale until the next refresh.

Class / Sibling gaps

Class: a generated Java identifier built from a COBOL name without checking that it is a legal Java identifier. Check the other camel() callers (gen.py:911 for paragraphs) and reserved words as well as a leading digit.

主要言語
Python
スター
57
フォーク
11
平均マージ
1時間 26分
マージ済み PR(30日)
974

環境構築

はじめの一歩

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

squid-protocol/gitgalaxy のほかの issue

squid-protocol/gitgalaxy の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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