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 395
    • Issues 395
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 27
    • Merge requests 27
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2448
Closed
Open
Created Feb 06, 2025 by Jordy Aaldering@JordyAalderingDeveloper

Type pattern incorrectly checks existence of variables

int[n:outer_shape] myTake1(int[n] outer_shape, int[d:shp] array)
    | (n <= d && all(outer_shape <= {[i] -> shp[i] | [i] < [n]}))
{
    return { iv -> array[iv] | iv < outer_shape };
}

Gives an error:

Condition contains an identifier 'i' that is not defined by an argument or a type pattern.

The issue is that when we encounter a type pattern condition, we check all identifiers within it to decide if that condition should be part of the pre-check or the post-check. We take all identifiers indiscriminately, which means that we also check [i] in the tensor comprehension.

To fix this we need to keep track of locally defined variables, such as i. Or alternatively, we just ignore variables that are not defined. The type checker will eventually figure out that this variable does not exist anyways. Depending on the quality of that error message we might just want to go for that approach, as it keeps the traversal simple, and also keeps the error messages consistent.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking