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 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
  • !405

Further improve create wrapper error messages and add CTIexplain.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Open Quinten Cabo requested to merge further-improve-create-wrapper-errors into develop May 16, 2025
  • Overview 21
  • Commits 3
  • Changes 6

In short this mr makes sure the void error message (b1) is only shown if there is actually no void version of the function available and now we always give all available versions of a function and take namespaces into account.

To show what this merge request does I am going to incrementally improve the error message I got.

Let's say you have this program:

void iota(int a, int b) {
    return;
}

int main() {
    Array::iota(3,3);
    return 1;
}

And you compile with -cti-no-source then you would get this error message:

  You are using the 'iota' function without using or assigning its result but no void returning implementation of iota exists.
  
  In SAC, if you do not use the result of a function application the overloading mechanism expects an implementation which returns void.
  None of the implementation of iota return void.
  
  Hint:
  • Assign the result to a variable e.g., 'result = iota(a)'
  • Or define a void-returning version `void iota(...) {}`)

In this scenario I found it annoying that it did not show which implementations were actually available.

This merge requests adds that in case b1 it will also always print the available implementations. This actually made the code a bit nicer by allowing me to use an CTIerrorBegin and CTIerrorContinued.

Making these changes and make it always show which versions are available gave me something like:

There is no instance of iota with 2 arguments and 0 return values.

You are using the 'iota' function without using or assigning its result but no void returning implementation of iota exists.

In SAC, if you do not use the result of a function application the overloading mechanism expects an implementation which returns void.
None of the implementation of iota return void.

Hint:
  • Assign the result to a variable e.g., 'result = iota(a)'
  • Or define a void-returning version `void iota(...) {}`)

Available implementations of iota include:
        iota(a, b)   (2 args) (0 returns)
    a = iota(a)      (1 arg)  (1 return)

There are several problems with this. First of all it says a void returning version does not exist but a void returning version does exist! Worse, it says that no version of iota with 2 arguments and 0 return values exist, but it does! Embarrassing.

The main problem here is that namespaces were not taken into account. This mr makes sure they are. After taking the namespaces into account I got something like:

There is no instance of Array::iota with 2 arguments and 0 return values.

You are using the 'Array::iota' function without using or assigning its result but no void returning implementation of it exists.

In SAC, if you do not use the result of a function application the overloading mechanism expects an implementation which returns void.
None of the implementation of iota return void.

Hint:
  • Assign the result to a variable e.g., 'result = Array::iota(a)'
  • Or define a void-returning version `void iota(...) {}`)

Available implementations of iota include:
        iota(a, b)          (2 args) (0 returns)
    a = Array::iota(a)      (1 arg)  (1 return)

This is much better and less confusing. If the namespace of a function is _MAIN I just don't print the namespace because I think it is unhelpful.

Then I enabled -cti-no-hint and got:

There is no instance of Array::iota with 2 arguments and 0 return values.

You are using the 'Array::iota' function without using or assigning its result but no void returning implementation of it exists.

In SAC, if you do not use the result of a function application the overloading mechanism expects an implementation which returns void.
None of the implementation of iota return void.

Available implementations of iota include:
        iota(a, b)          (2 args) (0 returns)
    a = Array::iota(a)      (1 arg)  (1 return)

I feel like the text In SAC, if you do ... should also be able to be suppressed, it would be annoying for intermediate sac programmers, but it is not a hint more like an explanation. To deal with this I added CTIexplain and -cti-no-explain which is the same idea as CTIhint but instead for the semantic meaning of explanations in error messages instead of hints. With -cti-no-explain it will now hide the explanation. This also made me prefix that explination with Explination:

In this process I also came up with the concept of a suggestion because in this file there is also the code that tries to suggest another function for you to use if a function with a similar enough name exists. This part used to be prefixed with Hint but did actually not use CTIhint. To not confuse the programmer I renamed this to a suggestion because I think this suggestion should always be given if available. Suggestions are hints that you can not suppress because they are just that good.

However, the explanation and hints are actually still wrong for this example because there is actually a version of iota that returns void, just with a different number of arguments. To fix this I added a check to actually check if there are no void returning functions instead of just the function application It will now only print the explanation and hint if there is actually no version that returns void at all.

Putting that in gives you:

There is no instance of Array::iota with 2 arguments and 0 return values.

Available implementations of iota include:
        iota(a, b)          (2 args) (0 returns)
    a = Array::iota(a)      (1 arg)  (1 return)

I also added some more comments and I tried to make the code more readable.

Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: further-improve-create-wrapper-errors