|
|
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
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.` |