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 15
    • Merge requests 15
  • 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
  • Empty file error

Empty file error · Changes

Page history
Extend Empty-file-error.md authored Mar 26, 2025 by Quinten Cabo's avatar Quinten Cabo
Hide whitespace changes
Inline Side-by-side
error-messages/Empty-file-error.md
View page @ 55216372
We could improve the error that you get when you try to compile an empty file by adding an example hello world program.
## Error now:
Currently, if you try to compile an empty file you get:
```
Error:
......@@ -9,17 +7,84 @@ Error:
Compilation failed while Loading SAC program, 1 error(s).
```
## Error Proposal
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
Compilation failed while Loading SAC program, 1 error(s).
Every program needs 1 main function.
Try a hello world program like this:
int main() {
show("Hello world!");
return 0;
}
```
\ No newline at end of file
Compilation failed while Loading SAC program, 1 error(s).
```
# Empty module
If you have this
```
module Bar;
int bar() { return 0; }
```
With no functions or no `exported` or `provided` functions you get this:
```
/tmp/SAC_YgFh4P/filenames.c:3: error: ISO C forbids an empty translation unit [-Werror=pedantic]
cc1: note: unrecognized command-line option ‘-Wno-use-after-free’ may have been intended to silence earlier diagnostics
cc1: all warnings being treated as errors
Abort:
System failed to execute shell command
/usr/bin/cc -fPIC -D_POS
```
We should improve this error message to say that the module is empty and that you can not compile empty modules because c does not allow it.
How would you detect that nothing is exported?
You could just check if the module has no export and no provides!
If there is at least one export or provide then at least it should be a different error message.
In that case you get:
```sac
module Bar;
export {barr}
```
Symbol 'barr' used in export or provide is not defined.
It would be a bit better if it just knew wether it was an export or a provide and not the or but this is not high priority.
But lets have a look anyways. ITs done.
```c
module Recursiveuse;
export {does,not};
provide {exist,here};
/**
./Recursiveuse.sac:4:17: error:
Symbol 'here' used in provide is not defined.
./Recursiveuse.sac:4:10: error:
Symbol 'exist' used in provide is not defined.
./Recursiveuse.sac:3:15: error:
Symbol 'not' used in export is not defined.
./Recursiveuse.sac:3:9: error:
Symbol 'does' used in export is not defined.
**/
```
We could improve this further by making one error out of this.
Undefined symbols in export: {does, not}
Or rephrase it like so `Exported symbol 'here' is not defined anywhere.`
Or [rephrase](./Anthropomorphic-error-essages.md) it like so `I could not find exported symbol 'here' defined anywhere.`
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