## Possible code changes ### General * DONE Use more specific messages when throwing a `SemanticFailure` exception. This has the caveat that the automated testing relies on those tests? ### StmtAnalyzer * DONE Propagate the change of class parameter from `ExprAnalyzer`. * DONE Complete checks for `MISSING_RETURN`, some ideas: * DONE Assume no instructions will appear after a return statement and analyze only the last `Stmt` using other visitor with different class parameters (for example passing the desired type and returning a `Optional`). * DONE Decide the logic behind a return statement in a `while` loop, maybe treat it as an `if` with an empty `else` block. * A `while` as last instruction is not a valid return. * A `if` as last instruction must have a valid return a the end of its then and otherwise blocks. ### ExprAnalyzer * DONE Change the second class parameter to give method AND class information (needed by var and this nodes) * DISCARDED Add a ClassSymbol to MethodSymbol and use it as class parameter, the problem arises when visiting a method, should an empty method with the proper class be provided? Could also be solved by using `Symbol` as class parameter. * DONE Create a new class that includes a `ClassSymbol` and a `MethodSymbol` and use that. Keep `MethodSymbol == null` when appropriate. ## Tests This tests have been selected to increase to 100% the code coverage obtained by running the tests designed for the previous HW, which are in folder svn/HW2/javali_tests/HW2_nop90 As they are mostly related to errors that haven't been triggered, each test should be separate, in order to generate all of the errors. ### Remaining ### Done * access var from class or superclass * test ! operator * type error in unaryOp * type error in array size * call method from superclass * call a method that doesn't exist * call a method with the wrong type of params * call a method with the wrong number of params * assign to all possible syntactically correct options * field * var * array index * method (error) * this (error) * indexing both types error * try to access a field of something that is not a class type * typing error in cast * AND and OR operations * equals operators (a case that is OK and another that's not) * binary operation with wrong type (any but == and !=) * search for a type that doesn't exist in a method body * don't have a Main class * don't have a main() method in the Main class (all possibilities) * wrong name * wrong return value * wrong parameters * inherited main method (it should work) * write something that is not an integer * declare a variable mutiple times (local variables) * declare a local variable with the same name as a parameter * check MISSING_RETURN * nested ifElse as end of method * while as end of method * normal returns at the end of the method * return with further statements after it * while with non-int condition * use a array type that hasn't been discovered yet * ```class A { B[] name; } class B {}``` * name a class Object * name a class like another class * name a parameter like another * override methods and try to break that * same return type * same number of params * same type of params * name a variable like another (field level)