Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,10 @@ data class DefineStmt(
}

if (originalDataDefinition != null) {
return listOf(InStatementDataDefinition(newVarName, originalDataDefinition.type, position))
val newType = if (originalDataDefinition.type is DataStructureType) {
StringType.createInstance(originalDataDefinition.elementSize())
} else originalDataDefinition.type
return listOf(InStatementDataDefinition(newVarName, newType, position))
} else {
if (!this.enterInStack()) {
// This check is necessary to avoid infinite recursion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.smeup.rpgparser.smeup

import com.smeup.rpgparser.db.utilities.DBServer
import com.smeup.rpgparser.interpreter.AbstractDataDefinition
import com.smeup.rpgparser.interpreter.DataDefinition
import com.smeup.rpgparser.interpreter.DataStructureType
import com.smeup.rpgparser.interpreter.StringType
import com.smeup.rpgparser.parsing.parsetreetoast.resolveAndValidate
import com.smeup.rpgparser.smeup.dbmock.MULANGTLDbMock
import org.junit.Test
import kotlin.test.*
Expand Down Expand Up @@ -887,4 +889,24 @@ open class MULANGT02ConstAndDSpecTest : MULANGTTest() {
assertIs<StringType>(ds0002DataDefinition?.type)
assertEquals(mlDataDefinition?.elementSize(), ds0002DataDefinition?.elementSize())
}

/**
* Definitions with *LIKE DEFINE referencing a DS must be defined as strings with the same size as the DS
* @see #LS25000333
*/
@Test
fun executeMUDRNRAPU00282() {
var aDefinition: AbstractDataDefinition? = null
var bDefinition: AbstractDataDefinition? = null

assertASTCanBeProduced("smeup/MUDRNRAPU00282", afterAstCreation = {
it.resolveAndValidate() // Needed to solve InStatementDataDefinitions
aDefinition = it.allDataDefinitions.firstOrNull { def -> def.name.equals("\$A", ignoreCase = true) }
bDefinition = it.allDataDefinitions.firstOrNull { def -> def.name.equals("\$B", ignoreCase = true) }
})

assertIs<DataStructureType>(aDefinition?.type)
assertIs<StringType>(bDefinition?.type)
assertEquals(aDefinition?.elementSize(), bDefinition?.elementSize())
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
V* ==============================================================
V* 24/01/2025 APU002 Creation
V* ==============================================================
O * PROGRAM GOAL
O * *LIKE DEFINE referencing a DS must be defined as
0 * strings with the same size as the DS
V* ==============================================================
O * JARIKO ANOMALY
O * Before the fix, they were defined as DS themselves
V* ==============================================================
D $A DS 512
C *LIKE DEFINE $A $B