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 22
    • Merge requests 22
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Wiki
  • Error messages
  • Overloading errorrs

Overloading errorrs · Changes

Page history
Simplified of overloading error messages to make them more useful authored Mar 26, 2025 by Quinten Cabo's avatar Quinten Cabo
Show whitespace changes
Inline Side-by-side
error-messages/Overloading-errorrs.md
View page @ 73c33702
......@@ -107,14 +107,12 @@ This error often triggers when:
1. a: The programmer calls a function that just does not exist anywhere
1. The function is named sel
2. There exists a simiarly named function, e.g. detect typo
2. There exists a similarly named function, e.g. detect typo
3. There does not exist a similarly named function.
2. b: The programmer calls a version of a function that does not exist
1. Not assigning the result of the function to a variable.
Calling the version that returns void, which often does not exist.
2. Only incorrect number of return values but more than 0.
3. Only incorrect number of arguments.
4. Incorrect number of arguments AND return values!
2. Incorrect number of arguments AND return values!
# a
......@@ -190,71 +188,20 @@ Hint:
• Or define a void-returning version `void %s(...) {}`)
```
## Info gathering for b2 b3 and b4
How do we know if the arity is right?
We need to ask two questions in order to get 3 awnsers.
1. Does an instance exist with the right amount of args?
2. Does an instance exist with the right amount of returns?
- If 1 and 2 then you wouldn't have the error so that never happens,
- If 1 and not 2 you had the wrong number of returns (case b2)
- If not 1 and 2 you had the wrong number of arguments (case b3)
- If not 1 and not 2 you had the wrong number of arguments and returns (case b4)
## b2
In this case we can say that the number of return values are wrong.
We can list the different numbers of valid return values.
At least get the different cases of functions.
We can still make the function type printer :)
```
Invalid call to foo:
The number of return values does not match any existing implementation.
Available implementations of foo include:
a, b = foo(...) (2 returns)
a, b, c = foo(...) (3 returns)
a, b, c, d = foo(...) (4 returns)
The number of arguments is correct. There is an instance with 1 argument.
```
## b3
In this case the we can say that the number of arguments is wrong.
We can list the different numbers of valid arguments.
```
"Invalid call to foo: the number of arguments does not match any existing implementation.
Available implementations of foo:
foo(arg1) (1 argument)
foo(arg1, arg2) (2 arguments)
foo(arg1, arg2, arg3) (3 arguments)
The number of return values is correct."
```
Hopefully we can get the types in there maybe or the arg names
## b4
In this case we say you got both the
In this case the arguments and the return values do not match an existing instance.
```
Invalid call to foo: the number of arguments and return values does not match any existing implementation.
Available implementations of foo:
a = foo(arg1) (1 argument, 1 return)
a, b = foo(arg1, arg2) (2 arguments, 2 returns)
a = foo(arg1, arg2, arg3) (3 arguments, 1 return)
a = foo(arg1) (1 argument) (1 return)
a, b = foo(arg1, arg2) (2 arguments) (2 returns)
a = foo(arg1, arg2, arg3) (3 arguments) (1 return)
```
Allign based on longest returns and longest arguments.
Align based on longest returns and longest arguments.
The tab at the start is nice!
## Type based suggestions
......
Clone repository
  • concepts
    • Deprecated Modules
    • Globals
    • Named Tuples
    • Overloading
    • Preprocessor
    • Primitive functions
    • Runetime Representations
    • input stdin
    • phm xt
    • ref counting methods
    • type famlies
    • type patterns
  • error messages
    • Anthropomorphic error essages
    • Colored error messages
    • Empty file error
View All Pages