feel-scala icon indicating copy to clipboard operation
feel-scala copied to clipboard

Fail to parse nested for-loop expression

Open saig0 opened this issue 1 year ago • 0 comments

Describe the bug The FEEL engine fails to parse a nested for-loop expression:

context merge(
  for entry in
    for kvPair in (for kvPair in split(rawContent, "\n") return kvPair) return split(kvPair, "=")
  return
    context put({}, entry[1], entry[2])
)

If I wrap the nested for-loop inside parenthesis, the FEEL engine can parse the expression:

context merge(
  for entry in
    (for kvPair in (for kvPair in split(rawContent, "\n") return kvPair) return split(kvPair, "="))
  return
    context put({}, entry[1], entry[2])
)

To Reproduce Steps to reproduce the behavior:

  1. Parse the expression above (Playground)
  2. Verify that the expression can't be parsed
failed to parse expression 'context merge(
  for entry in
    for kvPair in (for kvPair in split(rawContent, "\n") return kvPair) return split(kvPair, "=")
  return
    context put({}, entry[1], entry[2])
)': Expected (binaryComparison | between | instanceOf | in | "and" | "or" | end-of-input):1:9, found "merge(\n  f"

Expected behavior I can parse a nested for-loop without adding parenthesis.

Environment

  • FEEL engine version: 1.18.1
  • Affects:
    • Camunda Automation Platform 7: [7.x]
    • Zeebe broker: [0.x]

saig0 avatar Oct 07 '24 06:10 saig0