scalacenter / student-projects

The list of the available projects at the Scala Center for bachelor and master students.
8 stars 0 forks source link

TASTy Checker using tasty-query #13

Closed sjrd closed 1 year ago

sjrd commented 2 years ago

Description

The goal of this project is to build a compiler-independent checker for .tasty files, which ensures that .tasty files produced by the compiler adhere to the spec. It will use tasty-query for that purpose.

tasty-query is a library to load Scala 3 .tasty files, as well as Scala 2 pickles and Java class files. It provides semantic information about all the symbols and types in a program's classpath. For TASTy files, it also provides to full Typed Abstract Syntax Trees (typed AST) of all the classes and methods.

For every expression Tree in a program, tasty-query computes a Type. For example, it can compute the type scala.Int for an expression like 1 + 2. However, it does not check that expressions of certain types are only used where those types are valid. Consider for example:

def foo(x: String): Unit = println(x)

foo(1 + 2)

tasty-query will compute the type scala.Int for 1 + 2, and will know that foo expects one parameter of type java.lang.String, but it won't complain that it is an invalid call. That even though tasty-query knows that scala.Int is not a subtype of java.lang.String.

The compiler is supposed to catch these mistakes, so that it never produces .tasty files that are invalid. However, under separate compilation, or if there is a bug in the compiler, it could happen.

The TASTy Checker's job should detect and flag these cases, as well as many others.

Expected outcome

We expect the student to implement a TASTy Checker based on tasty-query. The checker should walk all the trees of TASTy file and validate the invariants of a well-typed program. Here is a non-exhaustive list of these invariants:

The first two bullets should definitely be addressed in the project. The extent to which other bullets and other invariants can be covered will be determined based on the progress.

Supervisor

Sébastien Doeraene (sebastien.doeraene@epfl.ch): principal engineer at the Scala Center

sjrd commented 1 year ago

This project will be taken by Guillem Bartrina as a master semester project in Spring 2023.