File tree Expand file tree Collapse file tree 3 files changed +33
-6
lines changed
rpgJavaInterpreter-core/src
main/kotlin/com/smeup/rpgparser/parsing/ast
kotlin/com/smeup/rpgparser/smeup Expand file tree Collapse file tree 3 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -1455,20 +1455,25 @@ data class DefineStmt(
1455
1455
val newVarName : String ,
1456
1456
override val position : Position ? = null
1457
1457
) : Statement(position), StatementThatCanDefineData {
1458
+ companion object {
1459
+ private val INDICATOR_PATTERN = Regex (" \\ *IN\\ (?(\\ d\\ d)\\ )?" , setOf (RegexOption .IGNORE_CASE , RegexOption .MULTILINE ))
1460
+ }
1461
+
1458
1462
override val loggableEntityName: String
1459
1463
get() = " DEFINE"
1460
1464
1461
1465
override fun dataDefinition (): List <InStatementDataDefinition > {
1462
1466
val containingCU = this .ancestor(CompilationUnit ::class .java)
1463
1467
? : return emptyList()
1464
1468
1465
- val indicatorPattern = Regex (" \\ *IN\\ d\\ d" )
1466
1469
val normalizedOriginalName = originalName.trim().uppercase()
1467
- val isIndicator = normalizedOriginalName.matches(indicatorPattern)
1468
- if (isIndicator) {
1469
- val indicatorKey = normalizedOriginalName.removePrefix(" *IN" ).toIndicatorKey()
1470
- val setStatements = containingCU.main.stmts.explode(true ).filterIsInstance<SetStmt >()
1471
- val definedIndicators = setStatements.map { it.indicators }.flatten().filterIsInstance<IndicatorExpr >()
1470
+ val indicatorMatch = INDICATOR_PATTERN .find(normalizedOriginalName)
1471
+ if (indicatorMatch != null ) {
1472
+ // First matching group is the indicator index
1473
+ val (indicatorIndex) = indicatorMatch.destructured
1474
+
1475
+ val indicatorKey = indicatorIndex.toIndicatorKey()
1476
+ val definedIndicators = containingCU.collectByType(IndicatorExpr ::class .java)
1472
1477
val isIndicatorDefined = definedIndicators.any { it.index == indicatorKey }
1473
1478
1474
1479
if (! isIndicatorDefined) throw Error (" Data reference $originalName not resolved" )
Original file line number Diff line number Diff line change @@ -946,6 +946,16 @@ open class MULANGT02ConstAndDSpecTest : MULANGTTest() {
946
946
assertEquals(aDefinition?.elementSize(), bDefinition?.elementSize())
947
947
}
948
948
949
+ /* *
950
+ * LIKE DEFINE on an indicator defined without a SET statement
951
+ * @see #LS25000738
952
+ */
953
+ @Test
954
+ fun executeMUDRNRAPU00283 () {
955
+ val expected = listOf (" ok" )
956
+ assertEquals(expected, " smeup/MUDRNRAPU00283" .outputOf(configuration = smeupConfig))
957
+ }
958
+
949
959
/* *
950
960
* Writing on a field of DS which use `EXTNAME` of a file. In this case the file in `EXTNAME` is different
951
961
* from `F` spec but shares same fields.
Original file line number Diff line number Diff line change
1
+ V* ==============================================================
2
+ V* 11/02/2025 APU002 Creation
3
+ V* ==============================================================
4
+ O * PROGRAM GOAL
5
+ O * *LIKE DEFINE referencing an indicator turned on with an eval
6
+ V* ==============================================================
7
+ O * JARIKO ANOMALY
8
+ O * Before the fix, jariko could not define XIN10
9
+ V* ==============================================================
10
+ C EVAL *IN10 = *ON
11
+ C *LIKE DEFINE *IN10 XIN10
12
+ C 'ok' DSPLY
You can’t perform that action at this time.
0 commit comments