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 19
    • Merge requests 19
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Wiki
  • Propsals ideas
  • Better error messages

Better error messages · Changes

Page history
Extend Better-error-messages.md with text about no main function or module authored Mar 26, 2025 by Quinten Cabo's avatar Quinten Cabo
Show whitespace changes
Inline Side-by-side
propsals-ideas/Better-error-messages.md
View page @ 0b94bdbd
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:
...@@ -18,3 +27,32 @@ Sorry, but only primitive functions are allowed to start with an _ (underscore) ...@@ -18,3 +27,32 @@ 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 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
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