mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-10 15:04:15 +03:00
fea01cfe4c
This uses the same disambiguation mechanism put in place for structures, calling the typer on individual rules on the desugared AST to propagate types, in order to resolve ambiguous operators like `+` to their strongly typed counterparts (`+!`, `+.`, `+$`, `+@`, `+$`) in the translation to scopelang. The patch includes some normalisation of the definition of all the operators, and classifies them based on their typing policy instead of their arity. It also adds a little more flexibility: - a couple new operators, like `-` on date and duration - optional type annotation on some aggregation constructions The `Shared_ast` lib is also lightly restructured, with the `Expr` module split into `Type`, `Operator` and `Expr`.
41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
> Include: common.catala_en
|
|
|
|
```catala
|
|
scope S:
|
|
definition z equals [
|
|
Structure { -- i: 3 -- e: Int content x };
|
|
Structure { -- i: 4 -- e: y };
|
|
Structure { -- i: 5 -- e: Dat content |1970-01-01| }
|
|
]
|
|
definition a equals number of (z ++ 1.1) / 2
|
|
```
|
|
|
|
```catala-test-inline
|
|
$ catala Typecheck
|
|
[ERROR] Error during typechecking, incompatible types:
|
|
--> decimal
|
|
--> collection
|
|
|
|
Error coming from typechecking the following expression:
|
|
┌─⯈ tests/test_typing/bad/err2.catala_en:10.38-41:
|
|
└──┐
|
|
10 │ definition a equals number of (z ++ 1.1) / 2
|
|
│ ‾‾‾
|
|
|
|
|
|
Type decimal coming from expression:
|
|
┌─⯈ tests/test_typing/bad/err2.catala_en:10.38-41:
|
|
└──┐
|
|
10 │ definition a equals number of (z ++ 1.1) / 2
|
|
│ ‾‾‾
|
|
|
|
|
|
Type collection coming from expression:
|
|
┌─⯈ tests/test_typing/bad/err2.catala_en:10.35-37:
|
|
└──┐
|
|
10 │ definition a equals number of (z ++ 1.1) / 2
|
|
│ ‾‾
|
|
|
|
#return code 255#
|
|
```
|