Skip to content

Commit

Permalink
Merge pull request #705 from smeup/bugfix/LS24003795/incongruou-defin…
Browse files Browse the repository at this point in the history
…ifion-between-two-ds-by-using-api

Bugfix/LS24003795/Incongruous definifion between two DS by using API
  • Loading branch information
lanarimarco authored Feb 7, 2025
2 parents bc2d503 + 2902848 commit 081a344
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2226,7 +2226,6 @@ internal fun <T : AbstractDataDefinition> List<T>.removeDuplicatedDataDefinition

internal fun AbstractDataDefinition.matchType(dataDefinition: AbstractDataDefinition): Boolean {
fun Type.matchType(other: Any?): Boolean {
// TODO: Improve logic for StringType/UnlimitedStringType matching
return when {
this is NumberType && other is NumberType -> {
val resultDigits = this.entireDigits == other.entireDigits && this.decimalDigits == other.decimalDigits
Expand All @@ -2235,7 +2234,11 @@ internal fun AbstractDataDefinition.matchType(dataDefinition: AbstractDataDefini
}
resultDigits
}
// TODO: Improve logic for StringType/UnlimitedStringType matching
this is UnlimitedStringType && other is StringType -> true
this is DataStructureType && other is DataStructureType -> {
return this.fields.intersect(other.fields).toList() == other.fields
}
else -> this == other
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,16 @@ class JarikoCallbackTest : AbstractTest() {
executeSourceLineTest("ERROR50")
}

@Test
fun executeERROR53SourceLineTest() {
executeSourceLineTest("ERROR53")
}

@Test
fun executeERROR53CallBackTest() {
executePgmCallBackTest("ERROR53", SourceReferenceType.Copy, "QILEGEN,£PDS", listOf(130))
}

@Test
fun bypassSyntaxErrorTest() {
val configuration = Configuration().apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,16 @@ open class MULANGT70CompilationDirectiveTest : MULANGTTest() {
val expected = listOf("FOO")
assertEquals(expected, "smeup/MUDRNRAPU00191".outputOf())
}

/**
* Strict inclusions, by `API` directive, of a DS already from caller program. This one declares `£UDLDA`,
* by using `/COPY QILEGEN,£PDS`, and appends to it other fields by using `/COPY QILEGEN,£C5PDS`.
* `MUDRNRAPU001101_API`, imported by `API` directive, imports only `£UDLDA`, without any addition.
* @see #LS24003795
*/
@Test
fun executeMUDRNRAPU001101() {
val expected = listOf("FOO", "BAR")
assertEquals(expected, "smeup/MUDRNRAPU001101".outputOf())
}
}
9 changes: 9 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/ERROR53.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/COPY QILEGEN,£PDS
/COPY QILEGEN,£C5PDS

/API QILEGEN,ERROR53_API

C EVAL £UDO2F = 'FOO'
C EVAL U$FUW2 = 'BAR'
C £UDO2F DSPLY
C U$FUW2 DSPLY
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
D/COPY QILEGEN,£PDS
D £UDO2I 1025 1025
21 changes: 21 additions & 0 deletions rpgJavaInterpreter-core/src/test/resources/QILEGEN/£C5PDS.rpgle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
D U$FUW2 1 400
D U$AMBI 1 2
D U$FUNZ 3 4
D U$METO 5 6
D U$TPOG 7 18
D U$CDOG 19 33
D U$PERT 34 35
D U$COND 36 37
D U$SCHE 38 38
D U$MODA 39 39
D U$51AZ 40 41
D U$51DV 42 44
D U$51ES 45 48
D U$LOGI 49 50
D U$STRP 51 51
D U$SANA 52 53
D U$TRPC 54 61
D U$COD$ 101 250 DIM(10)
D U$IMPO 251 400
D U$PRZA 401 401
D U$PARM 402 901
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
V* ==============================================================
V* 22/08/2024 APU001 Creation
V* 06/02/2025 API001 Changed name
V* 06/02/2025 API001 Improved description
V* ==============================================================
O * PROGRAM GOAL
O * Strict inclusions, by `API` directive, of a DS already
O * from caller program.
O * This one declares `£UDLDA`, by using `/COPY QILEGEN,£PDS`,
O * and appends to it other fields by using
O * `/COPY QILEGEN,£C5PDS`.
O * `MUDRNRAPU001101_API`, imported by `API` directive,
O * imports only `£UDLDA`, without any addition.
V* ==============================================================
O * JARIKO ANOMALY
O * Before the fix, the error occurred was
O * `Incongruous definitions of £UDLDA`.
V* ==============================================================
/COPY QILEGEN,£PDS
/COPY QILEGEN,£C5PDS

/API QILEGEN,MUDRNRAPU001101_API Jariko Runtime Error: `Incongruous definitions of £UDLDA`

C EVAL £UDO2F = 'FOO'
C EVAL U$FUW2 = 'BAR'
C £UDO2F DSPLY
C U$FUW2 DSPLY
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
D/COPY QILEGEN,£PDS
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
D U$FUW2 1 400
D U$AMBI 1 2
D U$FUNZ 3 4
D U$METO 5 6
D U$TPOG 7 18
D U$CDOG 19 33
D U$PERT 34 35
D U$COND 36 37
D U$SCHE 38 38
D U$MODA 39 39
D U$51AZ 40 41
D U$51DV 42 44
D U$51ES 45 48
D U$LOGI 49 50
D U$STRP 51 51
D U$SANA 52 53
D U$TRPC 54 61
D U$COD$ 101 250 DIM(10)
D U$IMPO 251 400
D U$PRZA 401 401
D U$PARM 402 901

0 comments on commit 081a344

Please sign in to comment.