Typechecking is fed an initial typing environment containing the symbols
defined by the stdlib. On the other hand, the term environment, used to
check for contract equality, was initialized empty, as a simplification
for this recent addition. This commit applies the same treatment for
both environment, and provides typechecking with an initial context
(typing env + term env). As a consequence, a few lines added in the REPL
also fix an earlier shortcoming of contract equality checking, which
wasn't effective in the REPL for symbols defined using top-level let.
The previous API of `Environment::get` was returning an owned value.
This doesn't correspond to the usual API for Rust containers. This
commit changes the API to return a reference instead, and let the caller
decide to clone the value or not.
Get rid of the useless separation between the global typing environment
and the current typing environment. It was done for performance reasons,
when cloning environments was expensive: but now, environments support
sharing, instead of having two separate environments, we can just start
for the initial (previously "global") and insert directly into it.
Doing so, rename "global" to "initial", which is now more faithful.
Since the refactoring of the typechecker with a distinct walk phase, the
typechecker now also walk contracts and type annotations. This caused
the LSP to panic in a lot of cases (basically, as soon as a contract is
attached to a field), due to scoping issues and breaking some invariants
of the LSP's linearizer.
This commit fixes that by creating a new proper scope() function for
walking contracts (scope_meta). It also removes the old code that used
to (imperfectly) handle contracts directly in the linearizer, dating
back to when the typechecker didn't process annotations.
* try to manage items without position in the lsp
* fix `linearisation::Completed::elem_at` and some code cleaning
Co-authored-by: Yann Hamdaoui <yann.hamdaoui@gmail.com>