Skip to content

Commit d3b733a

Browse files
committed
Recreate crash caused by missing name
Signed-off-by: worksofliam <[email protected]>
1 parent 84d625e commit d3b733a

File tree

2 files changed

+197
-0
lines changed

2 files changed

+197
-0
lines changed

tests/rpgle/issue453.rpgle

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
*
2+
dcl-f Custmast disk(*ext) usage(*input) KEYED USROPN INFDS(INFDS);
3+
dcl-f BALANCE disk(80) usage(*input) KEYED(*CHAR:7);
4+
dcl-f INVENTRY disk usage(*input:*output);
5+
dcl-f itemmast disk(*ext) usage(*input) KEYED USROPN
6+
EXTFILE('AIDDATA/MASTR');
7+
dcl-f Custmast disk(*ext) usage(*input) KEYED USROPN
8+
INFDS(INFDS);
9+
dcl-f balance disk(80) usage(*input) KEYED(*CHAR:7);
10+
dcl-f INVENTRY disk usage(*input:*output);
11+
dcl-f itemmast disk(*ext) usage(*input) KEYED USROPN
12+
EXTFILE('AIDDATA/MASTR');
13+
14+
D saved DS Qualified
15+
D max_RTN_AGE 5I 0 Inz(30)
16+
D max_ITEMS 5I 0 Inz(50)
17+
D max_CORE_RTN 5I 0 Inz(3)
18+
D max_ANY_RTN 5I 0 Inz(4)
19+
D ALLOW_CR_RTN 1N Inz(*ON)
20+
D ALLOW_SPEC_ORD...
21+
D 1N Inz(*OFF)
22+
D shortRound 1S 0
23+
D secondShort 3P 0
24+
// Charge VAT on CORE sales
25+
D chargeVATonCore...
26+
D 1N Inz(*OFF)
27+
D CHECK_TAG_NAME...
28+
D 1N Inz(*ON)
29+
D bondedStore 1N Inz(*OFF)
30+
D isBondedStore 1N Overlay(bondedStore)
31+
D isBonded 1N Overlay(bondedStore)
32+
D MAX_BIG_QTY 7P 0 Inz(10000)
33+
34+
D chargeVATonCore...
35+
D S 1N Inz(*OFF)
36+
D CHECK_TAG_NAME...
37+
D S 1N Inz(*ON)
38+
39+
D default DS Qualified
40+
D max_RTN_AGE 5I 0 Inz(30)
41+
D max_ITEMS 5I 0 Inz(50)
42+
// Fake comment 2
43+
D max_CORE_RTN 5I 0 Inz(3)
44+
D max_ANY_RTN 5I 0 Inz(4)
45+
D ALLOW_CR_RTN 1N Inz(*ON)
46+
// fake comments
47+
D ALLOW_SPEC_ORD...
48+
D 1N Inz(*OFF)
49+
D shortRound 1S 0
50+
D secondShort 3P 0
51+
// Charge VAT on CORE sales
52+
D chargeVATonCore...
53+
D 1N Inz(*OFF)
54+
D CHECK_TAG_NAME...
55+
D 1N Inz(*ON)
56+
D bondedStore 1S 0 Inz(0) BASED(ptr_veryLong...
57+
D namethatisAlsoAPointer)
58+
D isBondedStore 1N Overlay(bondedStore)
59+
D isBonded 1N Overlay(bondedStore)
60+
D MAX_BIG_QTY 7P 0 Inz(10000)
61+
62+
D chargeVATonCore...
63+
D S 1N Inz(*OFF)
64+
D CHECK_TAG_NAME...
65+
D S 1N Inz(*ON)
66+
67+
68+
* Variable MyString is a Java String object.
69+
dcl-s MyString OBJECT(*JAVA :'java.lang.String');
70+
dcl-pr bdcreate OBJECT EXTPROC(*JAVA: 'java.math.BigDecimal'
71+
:*CONSTRUCTOR);
72+
end-pr;
73+
74+
dcl-c MyConst CONST('These are the times to remember cause they will +
75+
not last forever. These arethe days to hold onto.');
76+
dcl-s Variable varchar(256) INZ('Gerkins');
77+
dcl-ds legacyPSDS PSDS;
78+
pgmname *PROC;
79+
status *STATUS;
80+
intJOBID int(10) POS(9);
81+
intSale4 bindec(5:2) POS(5);
82+
intSale2 int(5) POS(5);
83+
prevStatus zoned(3:0) POS(3);
84+
instNo packed(5:0) POS(5);
85+
exceptionData char(10) POS(10);
86+
exceptionID char(5) POS(5);
87+
jobName char(10) POS(10);
88+
wsid char(10) overlay(PSDS_LARGE_T:244);
89+
jobUser char(10) overlay(PSDS_LARGE_T:254);
90+
user char(10) overlay(PSDS_LARGE_T:254);
91+
jobNbr char(6) overlay(PSDS_LARGE_T:264);
92+
jobNo zoned(6:0) overlay(PSDS_LARGE_T:264);
93+
jobNumber zoned(6:0) overlay(PSDS_LARGE_T:264);
94+
D ThisIsAVeryLongDataStructure2...
95+
D extra 10A
96+
D ThisIsAVeryLongDataStructureName...
97+
D 10A
98+
D ThisIsAVeryLongDataStructureNameext...
99+
D DS
100+
D Qualified Inz
101+
D custNbr 7p 0
102+
D custName 10A
103+
104+
D custName S 10A
105+
D custName
106+
D S 10A
107+
dcl-ds custInfo EXTNAME('CUSTMAST') INZ;
108+
name EXTFLD INZ('UNKNOWN');
109+
D address E EXTFLD(adr)
110+
id_number EXTFLD('ID') INZ(-1);
111+
112+
dcl-ds *n PSDS;
113+
// What the actual fuck? Over.
114+
status pos(*STATUS);
115+
prevStatus zoned(5:0) overlay(PSDS_LARGE_T:16 );
116+
runLib char(10) overlay(PSDS_LARGE_T:81 );
117+
exceptionData char(80) overlay(PSDS_LARGE_T:91 );
118+
exceptionID char(4) overlay(PSDS_LARGE_T:171);
119+
jobName char(10) overlay(PSDS_LARGE_T:244);
120+
wsid char(10) overlay(PSDS_LARGE_T:244);
121+
jobUser char(10) overlay(PSDS_LARGE_T:254);
122+
user char(10) overlay(PSDS_LARGE_T:254);
123+
jobNbr char(6) overlay(PSDS_LARGE_T:264);
124+
jobNo zoned(6:0) overlay(PSDS_LARGE_T:264);
125+
jobNumber zoned(6:0) overlay(PSDS_LARGE_T:264);
126+
pgmCrtDate char(6) overlay(PSDS_LARGE_T:288);
127+
pgmCrtTime char(6) overlay(PSDS_LARGE_T:294);
128+
osvxry char(4) overlay(PSDS_LARGE_T:300);
129+
crtSrcFile char(10) overlay(PSDS_LARGE_T:304);
130+
crtSrcLib char(10) overlay(PSDS_LARGE_T:314);
131+
crtSrcMbr char(10) overlay(PSDS_LARGE_T:324);
132+
Module char(10) overlay(PSDS_LARGE_T:344);
133+
dcl-subf select char(10);
134+
dcl-subf chain char(10);
135+
end-ds;
136+
137+
dcl-ds LDA_DS1a DTAARA(*LDA);
138+
SUBFLD char(600) POS(1);
139+
end-ds LDA_DS1a;
140+
141+
dcl-ds LDA_DS1b DTAARA(*LDA:*AUTO:*USRCTL);
142+
SUBFLD char(50) POS(1);
143+
end-ds LDA_DS1b;
144+
145+
dcl-ds LDA_DS2a DTAARA(*LDA);
146+
SUBFLD char(600) POS(1);
147+
end-ds LDA_DS2a;
148+
149+
dcl-ds LDA_DS2b DTAARA(*LDA:*AUTO:*USRCTL);
150+
SUBFLD char(50) POS(1);
151+
end-ds LDA_DS2b;
152+
153+
154+
// *
155+
dcl-ds ALONE INZ;
156+
BASEPD zoned(8:3) POS(1);
157+
end-ds ALONE;
158+
// *
159+
dcl-ds *n DTAARA(*AUTO);
160+
WINV char(7) POS(2);
161+
WSTR char(2) POS(100);
162+
end-ds;
163+
dcl-s UINV packed(7:0); // Calc Spec work-field;
164+
dcl-s USTR packed(2:0); // Calc Spec work-field;
165+
166+
EVALR UINV = WINV;
167+
EVALR USTR = WSTR;
168+
// Calc Spec work-field
169+
170+
CHAIN CUSTNO CUSTMAST ;
171+
*IN32 = NOT %FOUND(CUSTMAST);
172+
173+
X = 0;
174+
175+
176+
dcl-proc system EXPORT;
177+
dcl-pi system int(10) extproc(*CWIDEN:'system');
178+
command varchar(256);
179+
end-pi system;
180+
end-proc;

tests/suite/basics.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from "path";
33
import setupParser, { getFileContent } from "../parserSetup";
44
import Linter from "../../language/linter";
55
import { test, expect } from "vitest";
6+
import { readFile } from "fs/promises";
67

78
const parser = setupParser();
89
const uri = `source.rpgle`;
@@ -1932,4 +1933,20 @@ test('that mixed symbols can be defined correctly', async () => {
19321933
expect(cache.constants.length).toBe(1);
19331934
expect(cache.variables.length).toBe(2);
19341935
expect(cache.procedures.length).toBe(1);
1936+
});
1937+
1938+
test('range issue #453', async () => {
1939+
const testSource = path.join(__dirname, `..`, `rpgle`, `issue453.rpgle`);
1940+
// const contents = await readFile(testSource, 'utf-8');
1941+
1942+
const lines = [
1943+
` D custName S 10A`,
1944+
` D custName`,
1945+
` D S 10A`,
1946+
` dcl-ds custInfo EXTNAME('CUSTMAST') INZ;`,
1947+
].join(`\n`);
1948+
1949+
const cache = await parser.getDocs(testSource, lines, { ignoreCache: true, withIncludes: false, collectReferences: true });
1950+
1951+
expect(cache).toBeDefined();
19351952
});

0 commit comments

Comments
 (0)