mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
41d6d3cbe9
Quite a few changes are included here, some of which have some extra implications visible in the language: - adds the `Scope of { -- input_v: value; ... }` construct in the language - handle it down the pipeline: * `ScopeCall` in the surface AST * `EScopeCall` in desugared and scopelang * expressions are now traversed to detect dependencies between scopes * transformed into a normal function call in dcalc - defining a scope now implicitely defines a structure with the same name, with the output variables of the scope defined as fields. This allows us to type the return value from a scope call and access its fields easily. * the implications are mostly in surface/name_resolution.ml code-wise * the `Scope_out` struct that was defined in scope_to_dcalc is no longer needed/used and the fields are no longer renamed (changes some outputs; the explicit suffix for variables with multiple states is ignored as well) * one benefit is that disambiguation works just like for structures when there are conflicts on field names * however, it's now a conflict if a scope and a structure have the same name (side-note: issues with conflicting enum / struct names or scope variables / subscope names were silent and are now properly reported) - you can consequently use scope names as types for variables as well. Writing literals is not allowed though, they can only be obtained by calling the scope. Remaining TODOs: - context variables are not handled properly at the moment - error handling on invalid calls - tests show a small error message regression; lots of examples will need tweaking to avoid scope/struct name or struct fields / output variable conflicts - add a `->` syntax to make struct field access distinct from scope output var access, enforced with typing. This is expected to reduce confusion of users and add a little typing precision. - document the new syntax & implications (tutorial, cheat-sheet) - a consequence of the changes is that subscope variables also can now be typed. A possible future evolution / simplification would be to rewrite subscopes as explicit scope calls early in the pipeline. That could also allow to manipulate them as expressions (bind them in let-ins, return them...) |
||
---|---|---|
.. | ||
.ocamlformat-ignore | ||
ast.ml | ||
desugaring.ml | ||
desugaring.mli | ||
dune | ||
fill_error_tokens.py | ||
fill_positions.ml | ||
fill_positions.mli | ||
lexer_common.ml | ||
lexer_common.mli | ||
lexer_en.cppo.ml | ||
lexer_en.mli | ||
lexer_fr.cppo.ml | ||
lexer_fr.mli | ||
lexer_pl.cppo.ml | ||
lexer_pl.mli | ||
lexer.cppo.ml | ||
name_resolution.ml | ||
name_resolution.mli | ||
parse_utils.ml | ||
parse_utils.mli | ||
parser_driver.ml | ||
parser_driver.mli | ||
parser_errors.mli | ||
parser.messages | ||
parser.mly | ||
print.ml | ||
print.mli | ||
surface.mld | ||
tokens.mly |