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(
14551455 val newVarName : String ,
14561456 override val position : Position ? = null
14571457) : Statement(position), StatementThatCanDefineData {
1458+ companion object {
1459+ private val INDICATOR_PATTERN = Regex (" \\ *IN\\ (?(\\ d\\ d)\\ )?" , setOf (RegexOption .IGNORE_CASE , RegexOption .MULTILINE ))
1460+ }
1461+
14581462 override val loggableEntityName: String
14591463 get() = " DEFINE"
14601464
14611465 override fun dataDefinition (): List <InStatementDataDefinition > {
14621466 val containingCU = this .ancestor(CompilationUnit ::class .java)
14631467 ? : return emptyList()
14641468
1465- val indicatorPattern = Regex (" \\ *IN\\ d\\ d" )
14661469 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)
14721477 val isIndicatorDefined = definedIndicators.any { it.index == indicatorKey }
14731478
14741479 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() {
946946 assertEquals(aDefinition?.elementSize(), bDefinition?.elementSize())
947947 }
948948
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+
949959 /* *
950960 * Writing on a field of DS which use `EXTNAME` of a file. In this case the file in `EXTNAME` is different
951961 * 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