Skip to content

Conversation

@yutaro-sakamoto
Copy link
Contributor

This pull request introduces a new validation step to detect and report duplicate paragraph (label) names within the same section of a COBOL program. This pull request will resolve #334

Label validation and error reporting:

  • Added the function cb_validate_labels in typeck.c to check for duplicate paragraph (label) names within the same section, reporting detailed errors when duplicates are found.
  • Declared cb_validate_labels in the header file tree.h for use in other modules.
  • Integrated label validation into the compilation pipeline in cobj.c by invoking cb_validate_labels for each program before further processing.

Test coverage improvements:

  • Expanded and updated the test suite in definition.at to cover cases with duplicate labels in the default section and named sections, ensuring that errors are correctly reported and that valid cases pass as expected.

@yutaro-sakamoto yutaro-sakamoto marked this pull request as ready for review December 16, 2025 04:10
Copilot AI review requested due to automatic review settings December 16, 2025 04:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds validation to detect and report duplicate paragraph (label) names within the same section of a COBOL program, resolving issue #334. The implementation introduces a new validation function that runs after parsing and before code generation, ensuring duplicate labels are caught early in the compilation process.

Key changes:

  • Added cb_validate_labels() function in typeck.c to detect duplicate paragraph names within sections
  • Integrated label validation into the compilation pipeline in cobj.c after parsing
  • Expanded test suite to cover duplicate labels in default and named sections

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
cobj/typeck.c Implements cb_validate_labels() function that iterates through the execution list, comparing paragraph names within each section and reporting duplicates with appropriate error messages
cobj/tree.h Adds function declaration for cb_validate_labels() to expose it for use in the compilation pipeline
cobj/cobj.c Integrates label validation by calling cb_validate_labels() for each program after parsing, returning error status if duplicates are found
tests/syntax.src/definition.at Expands test coverage with three test programs covering duplicates in the default section, named sections, and valid cases with same-named labels across different sections; tests both syntax-only and full compilation modes, including multiple program compilation scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yutaro-sakamoto yutaro-sakamoto changed the title Duplicate label3 Detect duplicate labels Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cobj cannot detect duplicated labels

1 participant