Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid cast in CrossCheck #1746

Closed
fm-117 opened this issue Jul 15, 2020 · 1 comment · Fixed by #1821
Closed

Invalid cast in CrossCheck #1746

fm-117 opened this issue Jul 15, 2020 · 1 comment · Fixed by #1821
Assignees
Labels
Bug Cobol Error User Visible Visible by the end user. Useful to priorize issue

Comments

@fm-117
Copy link
Contributor

fm-117 commented Jul 15, 2020

Describe the bug
An InvalidCastException is thrown for some programs in the CrossChecker if included copy contains nodes that are not DataDescription.

To Reproduce
Main program:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. DVZZMFT3.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 sometable.
       EXEC SQL
          INCLUDE somecopy
       END-EXEC.
       PROCEDURE DIVISION.
           GOBACK
           .
       END PROGRAM DVZZMFT3.

Included copy:

           EXEC SQL DECLARE Table1 TABLE
           ( Table1_Champ1 CHAR(1) NOT NULL,
             Table1_Champ2 CHAR(4) NOT NULL
           ) END-EXEC.

           05 table1-record.                                           
              10 table1-champ1 PIC X(1).
              10 table1-champ2 PIC X(4).

Exception will be thrown from here:

DiagnosticUtils.AddError(dataDescription, $"Cannot include copy {nextSibling.CodeElement?.FirstCopyDirective.TextName} " +

Expected behavior
No exception ! The CrossCheck should be able to handle any code coming from a copy although it would make it harder to detect level inconsistencies as originally intended.

@fm-117 fm-117 added Bug Cobol Error User Visible Visible by the end user. Useful to priorize issue labels Jul 15, 2020
@smedilol smedilol added this to the CobolEditor milestone Oct 30, 2020
@fm-117 fm-117 self-assigned this Dec 8, 2020
@fm-117
Copy link
Contributor Author

fm-117 commented Dec 8, 2020

After reviewing the example, it appears there are in fact 2 bugs:

  • the CrossChecker does not properly check the type of nextSibling before attempting cast
  • the real problem is that we should not even attempt to cast because parent node 01 somedate should have children

In the current implementation, EXEC nodes reset the current level and in the example EXEC SQL DECLARE... become a child of WORKING STORAGE SECTION, and thus sibling of 01 somedate and 05 table1-record. It is ok to attach the EXEC to its aprent section but this should not affect the level for the following DataDescription nodes.

mayanje added a commit that referenced this issue Jan 29, 2021
* WI #1357 Use hand-coded algorithm instead of regex to parse picture string

* WI #1260 Add unit test for GlobalStorage visibility

* Update develop with missing commits from master

* Issue #1185, add missing target detection

* Issue #1195, fix generate report if there is a warning

* Issue #1195, use appropriate property

* Issue #1243 Remove diagnostic: first char after continuation line should be a quotation mark

* WI #1243 Add parser test

* Issue #1244 Fix false positive if token is replaced

* WI #1363 Accept -glm option but do nothing with it

* WI #1385 Avoid NullReferenceException when completing a DEPENDING ON clause

Co-authored-by: Mayan Jean <[email protected]>
Co-authored-by: maxime645 <[email protected]>
Co-authored-by: fm-117 <[email protected]>

* WI #1627 Align csproj configuration properties and make use of Common.props

* WI #1262 Create Symbol and Type base classes (#1638)

Co-authored-by: Olivier Smedile <[email protected]>

* WI #1667 Update all NuGet dependencies and target .NET Framework 4.7

* WI #1667 Remove unused compilation configurations EI_Debug_Net40 and EI_Release_Net40

* WI #1667 Remove unused references

* WI #1667 Update to target framework 4.7

* WI #1667 Downgrade to language version C# 7.2

* WI #1667 Update to latest version all NuGet dependencies

* WI #1667 Fix duplicate Elastic/NLog references

* WI #1667 Fix compatiblity issues with dependent NuGets not targeting latest Newtonsoft version

* WI #1667 Fix JSON generated documentation according to new DataContractJsonSerializer results

* WI #1667 Update TypeCobol.* packages and Newtonsoft

* WI #1667 Revert to LangVersion 7.3

* WI #1679 Remove unused Moq dependency

* WI #1679 Remove unused dependency Castle.Core

* WI #1679 Remove -s|skeletons option

WI #1679 Update -s option deprecation message

* WI #1679 Remove unused Razor dependency

WI #1679 Remove references to .nuget folder in csprojs

* WI #1704 Disable codegen on EI-specific tests

* WI #1704 Remove unused condition

Fix after commit 9cefd7f

* WI #1704 Force codegen to false for EITests

* WI #1704 Adapt result file format to match current ExpectedResults

* WI #1133 Update GlobalStorage test with new Semantic errors

* Merge 1.4.3 into develop => remove skeletons reference

* WI #1721 Remove unused PassingDirection from CallTargetParameter

* WI #1721 Add Semantic Domain objects

* WI #1721 Activate symbols/types building in ProgramClassParserStep

* WI #1721 Use Semantic Domain during CrossCheck

- Paragraph/Section resolution
- Populate StorageArea to VariableSymbols dictionaries

* WI #1721 Add SYM comparator and SYM files for selected tests

* WI 960 ForbidSyncClauseWithStrictType (#1733)

* WI 960 ForbidSyncClauseWithStrictType -> rebase of #1729

* WI Forbid Sync clause with Strict Type #2

* WI 960 Forbid sync clause with strict type : rebase ProgramSymbolTableBuilder.cs from develop

* WI 1710 Check duplicate paragraph names with semantic data owner (#1736)

* WI 1710 Check duplicate paragraph names with semantic data owner

* WI #1710 Handle qualified name for paragraph resolution

* WI #1710 Handle paragraph resolution

* WI #1710 Handle section and paragraph declared with same name

* WI #1710 Change node type evaluation for better performance

* WI #1710 Corrections on code

* WI #1710 Move section node resolution algorithm into SymbolTable

* WI #1710 Remove unnecessary check on paragraphs

* WI #1710 Turn 'paragraph declared with a section name' into a Warning

* WI #1710 Avoid duplicate check for section and paragraphs having the same name

Co-authored-by: fm-117 <[email protected]>

* WI #1766 changing internal to public. (#1767)

Co-authored-by: mayanje <[email protected]>

* WI #1772 Upgrade NLog to v4.7.2 (#1775)

* WI #1780 Replace all placeholders in partial word replace operations (#1781)

* WI #1778 Fix numeric literal detection in scanner after THROUGH/THRU keyword (#1779)

* WI #1782 Allow "VALUE ARE"/"VALUES IS" in data condition value clauses (#1784)

* WI #1782 Allow "VALUE ARE" and "VALUES IS" syntaxes in data condition value clauses

* WI #1782 Extend test data with standard cases

* WI #1800 Disable CodeAnalysis for Debug-like configurations (#1801)

* WI #1103 Improve REMARKS directive parsing (#1804)

* WI #1103 Improve REMARKS directive parsing

* WI #1103 Trim trailing spaces only

* WI #1267 Implement CFG, add analyzer concept

* WI #1260 Integrate CFG builder as a new analyzer

* WI #1269 Add CFG tests

* WI #1777 Add support for comments mixed with continuation lines

* WI #1777 Include comments in continuation line groups in non-incremental mode

* WI #1777 Add LSR test for error reporting on continued lines

* WI #1777 Fix final ScanState for continuation line group

* WI #1789 Allow modification on input indices in procedures (#1793)

* WI #1785 Allow leading and/or trailing spaces in REPLACE placeholders (#1792)

* WI #1785 Allow leading and/or trailing spaces in REPLACE placeholders

* WI #1785 Add multiple spaces test case

* WI #457, #1671, #1791 Fix token attribution algorithm for continuation lines

* WI #1777 Include comments in continuation line groups in non-incremental mode

* WI #1777 Add LSR test for error reporting on continued lines

* WI #1777 Fix final ScanState for continuation line group

* WI #1791 Keep trailing spaces in literals from continued lines

* WI #457 Update MultiLines.cbl test

* WI #1791 #457 #1671 Rewrite token attribution algorithm for continuation lines

* WI #1791 Add unit test

* WI #457 Move SubscriptAndMultiLines test into regular test folder

* WI #1671 Add unit test

* WI #1671 Improve readability of SplitToken local function

* WI #1791 Update unit tests

* WI #1811 Avoid null indirection (#1817)

Co-authored-by: mayanje <[email protected]>

* WI #1622 Add unhandled exception handler. (#1812)

* WI #1622 Add unhandled exception handler.

* WI #1622 Enforce with AppDomain and add destructor

Co-authored-by: mayanje <[email protected]>

* 1752 handle copy replacing with 4colon ol (#1794)

* WI #1752 Implementation based on Partial Cobol Word

* WI #1752 removing trace code.

* #WI 1752 remove duplicate copy file.

* WI #1252 Moving test files

* WI #1752 Handle diagnostic one-char pseudo-text

* WI #1752 Review changes

* WI #1752 Review Changes

* WI #1752 Validation changes

* WI #1752 validation changes

* WI #1752 Review Changes

* WI #1752 Moving tests

* WI #1752 Remove return on continuation call: ApplyRemainingReplaces.

* WI #1752 move and remove some tests

* WI #1752 Change MDVZOSM to DVZOSM

* WI #1752 Remove spaces

Co-authored-by: mayanje <[email protected]>

* WI #1272 Implement Data Flow Analysis

* WI #1274 Add DFA tests

* WI #1275 Implement CALL targets detection using DFA

* WI #1746 Support EXEC SQL statements inside a data definition (#1821)

* WI #1192 #1724 Attach RENAMES to nearest level-01 (#1823)

* WI #1192 #1724 Attach RENAMES to nearest level-01

* WI #1724 Add RENAMES for a whole group in test

* WI #1120 Allow special registers in subscripts (#1843)

* WI #321 Add unit test for EXEC SQL INCLUDE on multiple lines (#1842)

* WI #321 Add unit test for EXEC SQL INCLUDE on multiple lines

* WI #321 Add unit test with full parsing

* WI #1816 Introduce new QualityCheck compilation step

* WI #1825 Add support for external code analyzers

* WI #1837 Add Violation class for quality analyzers

* WI #1676 Allow empty IF/ELSE constructs in Cup grammar (#1719)

* WI #1676 Allow empty IF/ELSE constructs in Cup grammar

* WI #1676 Check that parent is IF statement when visiting Then Node

* WI #1748 Check nature of separator after *CBL/*CONTROL keyword (#1840)

* WI #428 Rescanning Replaced Tokens. (#1798)

* WI #428 Rescanning Replaced Tokens.

* WI #428 fix for #599

* WI #428 Review Changes

* WI #428 Review changes

* WI #428 Clean up test and move code

* WI #428 Moving IsScanStateDependent in MultilineScanState

* WI #428 Code optimization

* WI #1200 Save SYNC alignment into a SyntaxProperty (#1841)

* WI #1200 Save SYNC alignment into a SyntaxProperty

* WI #1200 Improve diagnostic message with Sync alignment

* WI #1200  Fix sync param vs sync argument combinations in unit test

* WI #1837 Fix initial loading of predefined DiagnosticMessages

* WI #1808 Include missing copys from all levels

* WI #428 Handle token scan state dependent in DataDivision. (#1857)

* WI #428 Handle token scan state dependent in DataDivision.

* WI #428 review Changes

* WI #428 Review changes

* WI #428 Review changes

* WI #1851 Update Perfs Test source code. (#1859)

* WI #1851 Update Perfs Test source code.

* WI #1851 Using Ignore en main class.

* WI #1852 Avoid exception in DataDescriptionChecker on multiple VALUE clause contexts (#1856)

* WI #1834 Target .NET framework 4.7.2 (#1850)

* Revert "WI #1834 Target .NET framework 4.7.2 (#1850)" (#1866)

This reverts commit b4489ba.

* WI #1845 Add .xmldiag format for error output in CLI (#1862)

* WI #1864 Add peformance test with CFG/DFA (#1867)

* WI #1864 Add perormance test with CFG/DFA

* WI #1864 Remove AntlrPerformanceProfiler test

* WI #1864 Rename parseDocument

* WI #1864 Adapt performance test for Incremental with cfg/dfa.

* WI #1864 Review Changes

* WI #1869 Remove IASTAnalyzer, use QualityAnalyzer concept instead

Co-authored-by: fm-117 <[email protected]>
Co-authored-by: Olivier Smedile <[email protected]>
Co-authored-by: maxime645 <[email protected]>
Co-authored-by: rooksdo <[email protected]>
Co-authored-by: rooksdo <[email protected]>
Co-authored-by: fm-117 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Cobol Error User Visible Visible by the end user. Useful to priorize issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants