LARA

Simple Errors beyond Syntax

Some kinds or errors we can check using straightforward checks:

  • a class is defined more than once
  • a variable is defined more than once:
  • a class member is overloaded (forbidden in Tool, requires override keyword in Scala):
  • a method is overloaded (forbidden in Tool, requires override keyword in Scala):
  • a method argument is shadowed by a local variable declaration (forbidden in Java, Tool):
  • two method arguments have the same name:
  • a class name is used as a symbol (as parent class or type, for instance) but is not declared:
  • an identifier is used as a variable but is not declared:
  • the inheritance graph has a cycle:

To make it efficient and clean to check for such errors, we associate mapping from each identifier to the symbol that the identifier represents.

We use Map data structures to maintain this mapping.

The rules that specify how declarations are used to construct such maps are given by scope rules of the programming language.