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 393
    • Issues 393
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 24
    • Merge requests 24
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Merge requests
  • !288

Slightly improved type pattern errors

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Jordy Aaldering requested to merge better-type-pattern-errors into develop Mar 05, 2024
  • Overview 0
  • Commits 2
  • Changes 4

Example of incorrect function application:

int[n:shp,m:inner]
take(int[n] shp, int[n:outer,m:inner] arr)
{
    return { iv -> arr[iv] | iv < shp };
}

int main()
{
    arr = genarray ([3,5], 0);
    res = take ([1,2,3], arr);
    return res[0,0];
}

Produces an error: Type pattern error in application of take: dimensionality of argument 'arr' is too small, could not assign a non-negative value to 'm' in 'm:inner'


Example of incorrect function definition:

int[n:shp,m:inner]
take(int[n] shp, int[n:outer,m:inner] arr)
{
    return { iv -> arr[iv] | iv <= shp };
    //    <= instead of < here ^^^^
}

int main()
{
    arr = genarray ([3,5], 0);
    res = take ([1,2], arr);
    return res[0,0];
}

Produces an error: Type pattern error in definition of take: the found value of 'shp' in 'n:shp' of return value is not equal to the value of argument 'shp'

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: better-type-pattern-errors