Skip to content

Using Flatten on a list of list of literals fails validation #1187

@dschwartznyc

Description

@dschwartznyc

Steps to Reproduce:

  1. Define a Rune function that attempts to concatenate multiple lists using a list literal and the flatten operator:
    func TestListFunction:
        inputs:
            list1 number (1..*)
            list2 number (1..*)
        output:
            result number (1..*)
        set result:
            [list1, list2] flatten
    
  2. Generate code passing first through Rune validation

Expected Result:

Validation should succeed. The compiler should recognize that a ListLiteral containing multiple multi-cardinality elements results in a list of lists, which is the required input type for the flatten operator.

Actual Result:

Validation fails with the error:
List flatten only allowed for list of lists.

This occurs because CardinalityProvider.safeIsOutputListOfLists in rune-dsl lacks a specific case for ListLiteral, causing it to return false even when the literal effectively wraps multiple lists.

Environment:

  • Project: rune-dsl / rune-python-generator
  • OS: Mac
  • Runtime: Java 17

Additional Context:

The standard pattern for list concatenation is wrapping inputs in a collection and applying flatten. While the validator allows flatten on a single attribute that is explicitly defined as a list-of-lists, it fails to "see through" a ListLiteral used to group multiple lists for concatenation. This prevents the most common use case for flatten in functional expressions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions