Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 400
    • Issues 400
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 13
    • Merge requests 13
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2479
Closed
Open
Created May 01, 2025 by Jordy Aaldering@JordyAalderingDeveloper

Fold does not play nicely with type patterns

It seems we have a problem when combining fold and type patterns.

The following fails

int[n] minsl1(int[n,m] arr)
{
    return with {
        ([0] <= iv < [n]) : arr[iv];
    } : fold(ArrayArith::min, genarray([m], Constants::maxint()));
}

int[m] minv(int[m] a, int[m] b)
{
    return _min_VxV_(a, b);
}
No definition found for a function "ArrayFormat::minv" that accepts an argument
of type "int[.]" as parameter no 1. Full argument types are "( int[.], int[.])".

Removing the type patterns makes it work again:

int[n] minsl1(int[n,m] arr)
{
    return with {
        ([0] <= iv < [n]) : arr[iv];
    } : fold(minv, genarray([m], Constants::maxint()));
}

int[.] minv(int[.] a, int[.] b)
{
    return _min_VxV_(a, b);
}
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking