7326 Commits

Author SHA1 Message Date
Raphaël AMIARD
8eb6e10deb RA22-015: Add test for calls to non callable entities v22.0.0 2021-09-30 17:57:56 +02:00
Raphaël AMIARD
3035409823 RA22-015: Use match rt. cast+then
In SimpleTypeRef.check_correctness_pre. Also add some comments.
2021-09-30 17:57:56 +02:00
Raphaël AMIARD
f8264d9198 RA22-015: Fix resolution of calls to non statically resolvable fns 2021-09-30 17:57:56 +02:00
Raphaël AMIARD
da65c32d82 RA22-015: Fix call decl/type resolution
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
2021-09-30 17:57:56 +02:00
Raphaël AMIARD
39925cd8dc RA22-015: Fix to_iterator's signature
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.
2021-09-30 17:57:56 +02:00
Raphaël AMIARD
152ca4e491 RA22-015: Error when trying to call non callable entities
Also remove a dead branch in CallExpr.check_correctness_pre, and make
the code more readable/linear.
2021-09-30 17:57:56 +02:00
Raphaël AMIARD
83db168524 RA22-015: Remove dead branch 2021-09-30 15:21:08 +02:00
Raphaël AMIARD
50ed7ab4af RA22-015: Emit error on ambiguous type
Remove obsolete exception throwing code.
2021-09-30 15:21:08 +02:00
Romain Beguet
59cfc5d5b4 RA22-015: Fix dsl_unparse after recent changes. 2021-09-30 15:20:03 +02:00
Pierre-Marie de Rodat
ec3f81c78b langkit.libmanage: always print errors to stdout
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.
2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
8dfa522fa6 Add user-level doc for lexical environments
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
2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
ce934c2159 DSL: rework target environment in set_initial_env
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
2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
3058774a23 Lexical envs: turn env parents into simple lexical env values
Now that all env parents are simple refs, turn them from Env_Getter
(which allow dynamic refs) into simple lexical env value.

TN: T320-010
2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
2c9657239b $.Implementation: simplify the Add_Env helper
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
2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
af203f574f DSL: rework destination envs in add_to_env*
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
2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
b4f078ffd0 langkit.expressions.base.construct: minor typo fix 2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
44cdfac413 grammar/opt_info: stabilize test output
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
2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
1c3d7b6596 langkit.compiled_types.EnumType/EnumValue: add type hints
TN: T320-010
2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
2c3cb7b5f0 DSL: minor error message improvements for struct field type mismatches 2021-09-29 16:03:39 +02:00
Pierre-Marie de Rodat
397febf909 Python API: move type annotations to the generated sources
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
2021-09-29 11:11:14 +02:00
Laurent Thévenoux
b6e37cb968 testsuite: enable lkt semantic checks according to new PropertyError support
memoized_property_error is still set to False as it depends on another pending issue.
2021-09-28 16:36:06 +02:00
Laurent Thévenoux
3abafc526d prelude.lkt: add PropertyError struct 2021-09-28 16:36:06 +02:00
Laurent Thévenoux
1f3de54197 prelude.lkt: simple coding style fix 2021-09-28 16:36:06 +02:00
Pierre-Marie de Rodat
974bb7e174 langkit.common.bytes_repr: fix handling of quotes
Fix a typo which made this function mishandle quotes in String literals.
This bug made it impossible to add strings to Lkt's prelude.

TN: U922-031
2021-09-28 13:55:12 +02:00
Pierre-Marie de Rodat
eb3f9255e0 Lkt: minor docstring reformatting in Expr.expr_type_impl 2021-09-28 12:09:25 +02:00