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

Chiusa
#7,375 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
63/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java, python
Ambito
compilers

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
57
Fork
11
Merge medio
1h 32m
PR unite (30g)
974

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 squid-protocol/gitgalaxy

Tutte le issue di squid-protocol/gitgalaxy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.