testEuclid Failed to checkSemantics

Hi,
I have an error in testEuclid:

image

This is strange because I passed all the tests of the semantic check, is there any hint about the possibility of a NULL statement?

Thanks!

Reconsider what parts of statements may be missing / null, and you might realize what you have forgotten :slightly_smiling_face:

As an aside, you should really write your own tests. Your type checker is currently doing many things it should not be doing (like checking whether there is a return, even though its absence is not (!) a type error but simply undefined behavior), while also missing other important checks at other places, or doing things in the wrong order…

In general, do as we told you in the project presentation and stick precisely to the rules described in the project description. Please do not invent rules that do not actually exist.

Writing your own tests will help you spot these errors, since those tests would fail on the reference.

Thanks for the useful suggestion, my tests are in my local system and I did not upload them. So for a non-void function, we can even not return anything? As well, about the order, I can’t understand what role function declaration plays inside the code generation. And the last one, because the declaration is separate from the function definition and it looks like a global variable declared later is also checked earlier, which seems unavoidable.

Yes, see the project description.

It tells your compiler that that function exists “somewhere”. The code generated for a call to a declared function is exactly the same as the code generated for a function call to a defined function: A jal label, where that label has the same name as the function.

It’s not.

int foo(){ return x;}
int x;

does not typecheck.

1 Like

That makes sense! Thank you very much!