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 394
    • Issues 394
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 17
    • Merge requests 17
  • 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
  • !269

Add context message and return types to guards, and allow for multiple guard errors before aborting

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Jordy Aaldering requested to merge 2362-guard-add-context-and-types into develop Jan 23, 2024
  • Overview 16
  • Commits 44
  • Changes 43
  • Add a 'context' string to N_prf F_guard nodes to allow for more descriptive error messages by keeping track of the primitive function, or type pattern function, that is being guarded.
  • Add argument types to guard so that we can avoid guards from being optimised away based on dim or shape information, in cases where only the dim or shape of a returned value is needed. (In these cases, hideAkv would not be sufficient)
x1', .., xn' = _guard_ (x1, .., xn, type1, .., typen, pred1, .., predm);

Guards expects n values with corresponding types, and m boolean predicates. If all predicates are true then guard behaves as the identify function on arguments xi, otherwise an error will be raised. These guards serve as a barrier for optimisation and code rewrites around conformity checks and type pattern checks.

In order to be able to catch as many error messages as possible before aborting, a new primitive function _guard_error_ is added. It behaves similarly to _type_error_, however it prints a warning to the console and returns false, instead of aborting. This allows us to print multiple errors, after which the _guard_ function will catch this false value, and aborts the program. In the future this will allow us to also print a stack-trace at this point.

With this, we get multiple type pattern errors at once:

*** SAC runtime warning
*** In ./tests/type-patterns/test-type-pattern-multiple-errors.sac, line 11, column 1
*** Type pattern error in application of foo: feature `m:shp' in b does not match feature `shp' in a


*** SAC runtime warning
*** In ./tests/type-patterns/test-type-pattern-multiple-errors.sac, line 11, column 1
*** Type pattern error in application of foo: feature `o:shp' in c does not match feature `shp' in a


*** SAC runtime error
*** In ./tests/type-patterns/test-type-pattern-multiple-errors.sac, line 11, column 1
*** Type pattern pre-condition of foo failed

Closes #2362 (closed)

Edited Jan 26, 2024 by Jordy Aaldering
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: 2362-guard-add-context-and-types