|
|
|
|
|
This file holds the error messages that have been improved or added.
|
|
This file describes the in progress work to improve the error messages.
|
|
|
|
|
|
|
|
Let's just create simple expressions that should generate errors and then try to improve the error messages for those.
|
|
|
|
|
|
# Starting functions with _
|
|
|
|
|
|
|
|
This was actually an error that should have been raised, but it did not.
|
|
```c
|
|
|
|
|
|
The message for invalid function names simply reads: `invalid function name `%s' found`.
|
|
int main() {
|
|
|
|
a = [1,2,3];
|
|
|
|
print(a);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
I added a specific case for when a function name written by the programmer starts with an _
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
# Starting functions with _
|
|
|
|
|
|
|
|
Bodo thought that this was disallowed. But actually we should just discourage it.
|
|
A [MR](https://gitlab.sac-home.org/sac-group/sac2c/-/merge_requests/362) was made for this but maybe its not the best solution to the problem of compiler generated functions.
|
|
A [MR](https://gitlab.sac-home.org/sac-group/sac2c/-/merge_requests/362) was made for this but maybe its not the best solution to the problem of compiler generated functions.
|
|
|
|
|
|
## On a function call:
|
|
## On a function call:
|
... | @@ -17,4 +26,33 @@ Sorry, but only primitive functions are allowed to start with an _ (underscore) |
... | @@ -17,4 +26,33 @@ Sorry, but only primitive functions are allowed to start with an _ (underscore) |
|
|
|
|
|
## On a function definition:
|
|
## On a function definition:
|
|
|
|
|
|
Sorry, but function definition names are not allowed to start with an _ (underscore) character, but your '%s' function starts with an underscore. Please remove it. |
|
Sorry, but function definition names are not allowed to start with an _ (underscore) character, but your '%s' function starts with an underscore. Please remove it.
|
|
\ No newline at end of file |
|
|
|
|
|
# No main function or module
|
|
|
|
|
|
|
|
Currently, if you try to compile an empty file you get:
|
|
|
|
|
|
|
|
```
|
|
|
|
Error:
|
|
|
|
No declaration of module, class, or main function given
|
|
|
|
Compilation failed while Loading SAC program, 1 error(s).
|
|
|
|
```
|
|
|
|
|
|
|
|
This error is generated in the parser in the main `parse` function.
|
|
|
|
|
|
|
|
I improved this error by suggesting to add an example hello world program.
|
|
|
|
|
|
|
|
```
|
|
|
|
Error:
|
|
|
|
No declaration of module, class, or main function given
|
|
|
|
|
|
|
|
Every program needs 1 main function.
|
|
|
|
Try a hello world program like this:
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
show("Hello world!");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Compilation failed while Loading SAC program, 1 error(s).
|
|
|
|
``` |
|
|
|
\ No newline at end of file |