This fixes several bugs in the call decl/type resolution mechanism
* Generally make `called_decl` only return a called decl when there is
one for the specific callexpr. Before, for nested call expressions
like ̀ a () () ()` it would return the sub call-expression called decl.
* Make `expr_context_free_type` compute the type even when there is no
called declaration
Will be needed for an upcoming fix on call resolution. For the moment
to_iterator is unparsed as a regular function call in dsl_unparse, but
in the prelude it's a property, so unify towards it being a function.
Some discrepancies (see entity_iterator test) are ignored for the moment
due to a hole in type resolution.
Some tests may fail because of misplaced error messages in the test
output. This is due to sync issues between stdout and stderr. Instead of
Adding code complexity to flush stdout/stderr everywhere, only use
stdout for now. We might decide one day to move all diagnostic/error
messages to stderr.
This expands the previous langkit.envs module docstring, which was
ultra-minimal. Yet this new doc is still not exhaustive: there are
corner cases to document and more extensive examples to clarify things.
TN: T918-007
Similarly to what we did previously for add_to_env*, this commit merges
the set_initial_env and set_initial_env_by_name functions so that the
only function left takes a DesignatedEnv value.
This simplifies code generation (no need for a special env getter
function anymore) as well as the DSL interface.
TN: T320-010
Now that we unconditionally forbid foreign parents for lexical
environments, this helper no longer needs to handle dynamic env getters
for parents (both named envs and local envs are represented as a
pre-computed env value).
TN: T320-010
This commit reworks the add_to_env* functions in langkit.envs so that
it's programmatically possible in the property DSL to select a
destination environment either by name, by direct value, by current
environment or to have no destination environment (i.e. not to insert
anything in envs).
This introduces a new struct that is semantically a variant:
DesignatedEnv, whose alternatives match the possibilities described
above, removes add_to_env_by_name and changes the types of the current
"dest_env" arguments and struct fields to use DesignatedEnv instead.
This also adds new functions in langkit.expressions.envs (no_env,
current_env, named_env, direct_env) as DSL helpers to create values for
this new struct. Such helpers are useful to hide the cruft needed while
true variants are not available in the properties DSL.
TN: T320-010
The field serial number is an implementation detail and patches can
easily change them legitimately. Keep them out of the test output to
avoid superfluous baseline updates.
TN: T320-010
Now that the Python API support only Python 3.7+, we no longer have to
maintain the stubs for Mypy: we can directly use type annotations in the
generated Python code. This uncovered several typing issues, which led
to several typing improvements.
TN: U720-016