Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The for loop wrongly behaves when there are nested arrays in the iteration contexts #1350

Closed
yesamer opened this issue Jun 24, 2024 · 4 comments · Fixed by apache/incubator-kie-drools#6041
Assignees
Labels
area:dmn Related to DMN area:engine Related to the runtime engines type:bug Something is behaving unexpectedly

Comments

@yesamer
Copy link

yesamer commented Jun 24, 2024

The following FEEL expression:

for x in [ [1,2], [3,4] ], y in x return y

should return [1, 2, 3, 4]

but it currently returns [1, 2, 1, 2]

@yesamer yesamer added type:bug Something is behaving unexpectedly area:dmn Related to DMN area:engine Related to the runtime engines labels Jun 24, 2024
@yesamer yesamer changed the title The for cycle wrongly behaves when there are nested arrays in the iteration contexts The for loop wrongly behaves when there are nested arrays in the iteration contexts Jun 24, 2024
@yesamer
Copy link
Author

yesamer commented Jun 24, 2024

Most likely related to #774

@yesamer
Copy link
Author

yesamer commented Jul 25, 2024

//cc @bncriju

@gitgabrio gitgabrio moved this from 📋 Backlog to ⏳ In Progress in 🦉 KIE Podling Board Aug 6, 2024
@gitgabrio
Copy link

gitgabrio commented Aug 6, 2024

@yesamer
I've found the point where it fails, but it is int the core logic itself, where during the loop evaluation, only the first element is stored (and retrieved ) as x variable (so, the [1, 2] in the given example):

I'm trying also another example
for x in [ 1, 2, 3, 4 ], y in x return y
that, apparently, should return [1, 2, 3, 4]
but it also returns [1, 1, 1, 1] (since 1 is the first x element)

@gitgabrio
Copy link

gitgabrio commented Aug 6, 2024

@yesamer @baldimir
Reading spec:

An iteration context may either be an expression that returns a list of elements, or two expressions that return
integers connected by “..”. Examples of valid iteration contexts are:
• [ 1, 2, 3]
• a list
• 1..10
• 50..40
• x..x+10
• @”2021-01-01”..@”2022-01-01”

and

for i in [i1,i2], j in [j1j2] return e = [ r1, r2, r3, r4 ]

it seems that this expression is wrong
for x in [ 1, 2, 3, 4 ], y in x return y (x is always a number)

but this should work

for x in [ [1,2], [3,4] ], y in x return y (x is alway a list)

Unfortunately, it seems that our implementation is expecting only statically defined lists.

I'm digging further...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dmn Related to DMN area:engine Related to the runtime engines type:bug Something is behaving unexpectedly
Projects
Status: 🎯 Done
2 participants