🐞️ Functions: Return position enforcement (#6)
* Parser - Added a TODO in `wantsBody == true` case in `parseFuncDef()` to check for the return keyword's position * Parser - Added a check in `parseFuncDef()` which, is a `ReturnStmt` is found, then crash the parser if it is found anywhere besides the last statement * Test cases - Added test cases to test the `return` statement position enforcementresearch/gmalloc
parent
dad185f96f
commit
a4c010f27f
@ -0,0 +1,12 @@
|
||||
module simple_return_bad;
|
||||
|
||||
int myFunction()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int myFunction2()
|
||||
{
|
||||
return 2;
|
||||
int j = 1;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
module simple_return_good;
|
||||
|
||||
int myFunction()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
int myFunction2()
|
||||
{
|
||||
int j = 1;
|
||||
return 2;
|
||||
}
|
Loading…
Reference in New Issue