Commit Graph

640 Commits

Author SHA1 Message Date
Louis Gesbert
c249cef3cc Printer: flatten nested let-ins too 2023-05-02 11:53:30 +02:00
Louis Gesbert
3e7a2a34ab More printer improvements 2023-05-02 11:49:09 +02:00
Denis Merigoux
c6bafe8896
Update assets and tests 2023-05-02 10:58:45 +02:00
Denis Merigoux
7788bf9e73
Error message when two same states 2023-04-27 15:37:11 +02:00
Denis Merigoux
9b056f3ca1
Update assets and fix errors after rebase 2023-04-27 12:18:50 +02:00
Denis Merigoux
40af4d3a46
Disable optimization that was messing with the Proof backend 2023-04-27 12:13:18 +02:00
Denis Merigoux
7517894f77
Restore positions in test 2023-04-27 12:10:47 +02:00
Denis Merigoux
75c2a24b98
Changed position formatting 2023-04-27 12:09:22 +02:00
Denis Merigoux
19b33eaa96
Add lint and fix bugs related 2023-04-27 12:09:22 +02:00
Denis Merigoux
2d34fe7f27
Added a test related to #449 2023-04-27 12:09:22 +02:00
Denis Merigoux
081e60d2c6
Restore tests due to restored optimizations for default terms 2023-04-21 14:55:56 +02:00
Denis Merigoux
22b24a8634
Fusion of all optimizations done correctly 2023-04-21 12:32:09 +02:00
Denis Merigoux
f9a6644da3
Cleanliness and aesthetics 2023-04-18 15:45:30 +02:00
Denis Merigoux
4a1efcaa12
Restore tests and update assets 2023-04-18 14:46:25 +02:00
Denis Merigoux
0ec75ad589
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-18 14:37:02 +02:00
Denis Merigoux
c5ba3e72fe
Restore CI 2023-04-18 09:59:24 +02:00
Denis Merigoux
ecccb5fb91
Last changes 2023-04-18 09:59:24 +02:00
adelaett
5d1f293fa0
finished looking at all tests 2023-04-14 18:27:20 +02:00
adelaett
70679b529b
adding some messages in new test files 2023-04-14 18:24:09 +02:00
adelaett
5e46253140
removed one remaning debuging print, and updating all the tests 2023-04-14 17:59:08 +02:00
adelaett
bc6e149618
same 2023-04-14 17:35:28 +02:00
adelaett
6f7d3422a4
more tests 2023-04-14 17:03:15 +02:00
adelaett
f3a5cbc5a8
test_typing err6 better error message 2023-04-14 16:37:27 +02:00
adelaett
a11ec6020e
commit not passing test about closure conversion 2023-04-14 16:34:37 +02:00
adelaett
e5d518af69
more fixing 2023-04-14 16:28:37 +02:00
adelaett
5f3584c94d
fixing more tests 2023-04-14 16:25:22 +02:00
adelaett
91805bfa43
fixing tests 2023-04-14 16:22:39 +02:00
adelaett
a9809b69a9
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-14 11:19:58 +02:00
Louis Gesbert
e19e4af12d Vastly improve the printer
* fix lots of Format boxes
* add parens based on precedence in the printer
* fix interaction of Format and the colored line debug tags
2023-04-13 18:15:22 +02:00
adelaett
43c1fd9b7e
adding tests 2023-04-12 11:38:12 +02:00
alain
ec40de83fc
Merge branch 'master' into adelaett-withoutexceptionsfix 2023-04-06 13:57:22 +02:00
Denis Merigoux
ad02a0959d
Merge branch 'master' into aides_logement_outre_mer 2023-04-03 14:12:10 +02:00
Denis Merigoux
d147238088
Apply suggestions by @altgr 2023-04-03 13:42:14 +02:00
Denis Merigoux
e80143b3ca
Last linting pass and update tests 2023-03-31 17:56:45 +02:00
Denis Merigoux
5673708f36
Update assets 2023-03-31 15:34:51 +02:00
Denis Merigoux
3d86a12261
Update error messages 2023-03-31 14:01:04 +02:00
Denis Merigoux
04629f58cd
Merge branch 'master' into aides_logement_outre_mer 2023-03-30 15:14:06 +02:00
adelaett
6dee3874cc Merge branch 'master' into adelaett-withoutexceptionsfix 2023-03-30 10:50:32 +02:00
Aymeric Fromherz
b85a199daa
Add support for let .. in constructions in Z3 backend (#434) 2023-03-29 06:41:40 +09:00
Aymeric Fromherz
8780a48312 Correct test invocations 2023-03-28 22:51:03 +09:00
Aymeric Fromherz
d0ef61219f Add expected outputs for tests 2023-03-28 13:03:44 +09:00
Aymeric Fromherz
8fdd39d15a Add negative test for let_in 2023-03-28 13:01:41 +09:00
Aymeric Fromherz
71ebd3a2c7 Test for Z3 let_in 2023-03-28 12:49:14 +09:00
Denis Merigoux
b801cccd15
Update tests 2023-03-21 13:32:38 +01:00
Denis Merigoux
aa8ab3be3d
Merge branch 'master' into c_backend 2023-03-21 12:14:10 +01:00
Denis Merigoux
b2d02f4b0f
Fixed all tests 2023-03-17 18:44:19 +01:00
Denis Merigoux
7f705beb07
Merge branch 'master' into aides_logement_outre_mer 2023-03-17 17:52:10 +01:00
Raphaël Monat
d5cd5b206a Show conflicting date rounding mode declarations when they happen 2023-03-16 18:51:01 +01:00
Raphaël Monat
8981b21edb Add test for date rounding option conflict 2023-03-16 17:20:14 +01:00
Raphaël Monat
5cf6bdffb8 Add tests for date rounding option 2023-03-16 17:20:13 +01:00
Denis Merigoux
74df4ee988
Merge branch 'master' into aides_logement_outre_mer 2023-03-14 14:10:09 +01:00
Louis Gesbert
6388a4b79f Improved some error messages (cyclic defs, def positions) 2023-03-08 15:27:48 +01:00
Denis Merigoux
bfc827296c
Merge branch 'master' into aides_logement_outre_mer 2023-03-06 14:09:51 +01:00
Louis Gesbert
97e0cfca6f Improvements on function arguments refactoring
- simplify naming in the french law examples
- make messages yet more precise on function arguments mismatch
2023-03-02 19:11:21 +01:00
Louis Gesbert
fc5910e093 Fix multi-argument scopedefs, improve error message positions
This adds a few positions to the parser, and tweaks some others, vastly
improving the reporting of some errors (inconsistent functions definitions, but
also exceptions cycles, etc.)
2023-02-28 15:53:50 +01:00
Louis Gesbert
2c97d5de14 Enforce consistency of function arguments naming 2023-02-28 15:53:50 +01:00
Louis Gesbert
8200457e43 Syntax change: require declaration of function argument names 2023-02-28 15:53:50 +01:00
Louis Gesbert
6b44d19919 Tests: add function parameter inconsistency checks 2023-02-28 15:53:50 +01:00
Denis Merigoux
0667e3d40f
Merge branch 'master' into aides_logement_outre_mer 2023-02-28 15:01:31 +01:00
adelaett
621b4bd974 add of an example with partial code duplication (non-exponential) 2023-02-28 08:36:45 +01:00
Louis Gesbert
5bd140ae5f
Arrow List (#404) 2023-02-22 14:06:55 +01:00
adelaett
9f31715a47 style 2023-02-22 12:11:42 +01:00
adelaett
9a3a318ee0 updated the output of functions, since we now generate functions with multiple parameters 2023-02-21 14:18:35 +01:00
adelaett
e9f8843e4f adding one simple test about toplevel definitions 2023-02-21 14:17:58 +01:00
adelaett
a59a2f77fc typos in readme 2023-02-21 14:17:30 +01:00
Louis Gesbert
8c40b1ddd0 Fix python output of toplevel defs
there is room for name clashes there though, maybe we should find a more
consistent renaming mechanism
2023-02-17 19:59:22 +01:00
Louis Gesbert
c3af0b4097 Toplevel definitions: branch cleanup
- fix remaining warnings (mostly unused arguments)
- renamings throughout for consistency and clarity
2023-02-13 18:02:09 +01:00
Louis Gesbert
912e1500c4 Handle toplevel defs down to scalc 2023-02-13 11:44:32 +01:00
Louis Gesbert
6f1ac5837d Add syntax for calling multi-argument functions
* temporary and undocumented while waiting for discussion an approval
* previous patches already allowed definition (at toplevel) but there was no
syntax for calls
* no syntax for multi-args _local_ functions yet
2023-02-13 11:44:32 +01:00
Louis Gesbert
d66cd1e29c Toplevel defs: tests & fixes 2023-02-13 11:44:32 +01:00
Denis Merigoux
d7df6b3e80
Typing now takes into account [TAny] in structs/enums 2023-02-08 16:00:53 +01:00
Denis Merigoux
c78a004b53
Leave everything unresolved for now 2023-02-08 16:00:53 +01:00
Denis Merigoux
7d6abf36b2
Taking into account that closures can be input and output of scopes 2023-02-08 16:00:21 +01:00
Denis Merigoux
6906fa48d1
Fix test for CI 2023-02-08 16:00:21 +01:00
Denis Merigoux
3577507ee9
Switch from closure-passing to environment-passing closure conversion 2023-02-08 16:00:21 +01:00
Denis Merigoux
4521d05839
Starting to implement hoisting 2023-02-08 15:59:51 +01:00
Denis Merigoux
47c6746982
One test passing 2023-02-08 15:59:51 +01:00
Denis Merigoux
83e9e83909
Progressing [skip ci]
Testing with dune exec catala -- Lcalc -s S tests/test_func/good/closure_conversion.catala_en  --avoid_exceptions -O --closure_conversion
2023-02-08 15:59:51 +01:00
Denis Merigoux
21d4360120
Add verification condition special case for scope context arguments 2023-01-20 15:55:28 -05:00
Denis Merigoux
ec6616c091
Changing encoding of direct scope call to avoid empty error confusing static analysis 2023-01-20 15:23:50 -05:00
Denis Merigoux
8405d243be
Fix compiler and tests 2023-01-20 14:10:18 -05:00
Denis Merigoux
7cffc53169
Merge branch 'master' into afromher_334 2023-01-20 14:05:38 -05:00
Denis Merigoux
cd4f7db547
Removed useless file 2023-01-13 11:57:56 +01:00
Denis Merigoux
2f4a51ce64
Bug fixed! It was tricky 2023-01-07 20:22:36 +01:00
Denis Merigoux
9c6a126af3
Update formatting 2023-01-07 18:38:02 +01:00
Denis Merigoux
c723249337
Managed to find a MWE of the bug 2023-01-06 17:07:43 +01:00
Louis Gesbert
2003566867 Force parens in compound logic formulas
Closes #373

This forbids expressions such as `a and b or c`, avoiding the need to set an
implicit priority between `and`, `or` and `xor`, which I find error-prone.

Instead, when that appears, a message asking for explicit parentheses will be
shown to the user.

Implementation note: since that would be extremely tedious to do in the parser
directly, the parser is set to allow right-associativity without discrimination
for the logical operators, and the check is done during desugaring. This
required to explicit parentheses in the surface AST to discriminate the case
where the priority was explicit.
2023-01-04 10:46:14 +01:00
Louis Gesbert
51df581aba Small cleanup/fixes following PR review on Syntax Changes 2022-12-20 16:03:41 +01:00
Louis Gesbert
9e514755b7 Collection syntax: re-add combined filter+map 2022-12-19 15:17:17 +01:00
Louis Gesbert
47502335aa Refactor the parser to use priorities
Define a single expression rule with disambiguation using token priorities
instead of the many layers of intermediate rules with explicit sub-terms.

Also replaces `in` for collection operations (`x+1 for foo in [1;2]`) with
`among` which helps a lot.
2022-12-19 15:12:53 +01:00
Louis Gesbert
f236e2cfb2 Replace the type conversion and rounding operators with overloads
Ref. #366

Also updates `CONTRIBUTING.md`.

This was pretty straight-forward :)
2022-12-13 15:32:49 +01:00
Louis Gesbert
c94509e0bb Remove integer division from the language
it's unlikely to be used in any law, and likely to be cause for confusion.

best of all, the new operator has a different return type, which
ensures no inconsistency with the change can get overlooked.
2022-12-13 12:35:02 +01:00
Louis Gesbert
dcb422302d Tests/examples update 2022-12-13 12:30:40 +01:00
Louis Gesbert
bb58d11ca8 Improve syntax for scope calls
implements #357
2022-12-13 12:30:38 +01:00
Louis Gesbert
09d49ab1cc French syntax: replace 'sortie' with 'résultat'
as per comment in #357
2022-12-13 12:27:33 +01:00
Louis Gesbert
71bb67163c Remove explicitely typed operators in tests and examples
Command used: `sed -i 's/\([-+*/><=]=\?\)[.$@^€$]/\1/g' **/*/*.catala_*`

The overload test, of course, is kept unchanged and ensures that explicit
operators still work.
2022-12-13 12:00:04 +01:00
Louis Gesbert
fea01cfe4c Add overloaded operators for the common operations
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`.
2022-12-13 11:55:24 +01:00
Louis Gesbert
5bcc0a65eb Improve some messages on structure disambiguation 2022-12-13 11:47:21 +01:00
Denis Merigoux
619461dba8
Merge branch 'master' into fix_362 2022-12-07 15:32:08 +01:00
Denis Merigoux
e448a1a1b4
Fix 362 (was harder than expected and unit tests helped catch subsequent encoding bugs!) 2022-12-02 16:42:29 +01:00
Denis Merigoux
eee9946847
Fix extra error on empty 2022-12-02 12:07:26 +01:00
Denis Merigoux
6523181ec7
Wrote unit tests before fix 2022-12-01 18:14:03 +01:00
Louis Gesbert
4ee4a96ac7 Remove *all* struct field access qualifiers in catala code
They are no longer needed \o/
2022-11-28 16:42:02 +01:00
Louis Gesbert
8960e5dbbc Add typing-based disambiguation pass after desugaring
Some typing errors are changed a little, because they get triggered during the
typing of the disambiguation pass, which does not specify the expected return
type (it's an expected invariant that it should not be needed for
disambiguation).

It would be possible to still specify these types during disambiguation just to
get the same errors, but since the newer ones don't appear to be clearly worse
at the moment, it has not been done.
2022-11-28 16:38:09 +01:00
Louis Gesbert
c92fe5e72d Fix underline of code errors when code contains utf8 2022-11-28 16:38:09 +01:00
Louis Gesbert
af2f5dbe19 Tweak error message location printing 2022-11-28 16:38:09 +01:00
Louis Gesbert
a5ea9451bc Fix extra spacing in struct printer 2022-11-21 17:11:53 +01:00
Louis Gesbert
4ae392c900 AST refactoring
Many changes got bundled in here and would be too tedious to separate.

Closes #330

See changes in `shared_ast/definitions.ml` to check the main point.

- the biggest change is a modification of the struct and enum types in
  expressions: they are now stored as `Map`s throughout passes, and no longer
  converted to indexed lists after scopelang. Their accessors are also changed,
  and tuples only exist in Lcalc (they're used for closure conversion).

  This implied adding some more information in the contexts, to keep the mapping
  between struct fields and scope output variables. It should also be much more
  robust (no longer relying on assumptions upon different orderings).

- another very pervasive change is more cosmetic: the rewrite of the main AST to
  use inline records, labelling individual subfields.

- moved the checks for correct definitions and accesses of structures from
  `Scope_to_dcalc` to `Typing`

- defining some new shallow iterators in module `Shared_ast.Expr`, and
  factorising a few same-pass rewriting functions accordingly (closure
  conversion, optimisations, etc.)

- some smaller style improvements (ensuring we use the proper compare/equal
  functions instead of `=` in a few `when` closes, for example)
2022-11-17 18:16:09 +01:00
Aymeric Fromherz
e37ad1de44 Reset tests 2022-11-08 22:28:02 +01:00
Aymeric Fromherz
63572b6963 Add bad test for assertions 2022-11-08 22:27:17 +01:00
Aymeric Fromherz
4af44fb519 Add debug info about encoded assertions 2022-11-08 22:25:07 +01:00
Aymeric Fromherz
9ad7362381 Add testcase from issue 2022-11-08 20:38:09 +01:00
Louis Gesbert
f8f1ae283f Scopelang printer: use 'struct'/'enum' rather than 'type' 2022-11-07 14:13:03 +01:00
Louis Gesbert
4d4dac6727 Some fancy unicode for error outlines
Normally I would make sure this is not by default, or at leat disableable; but
here the code we print may contain utf8 anyway, so the terminal really needs to
support it. Anyway, it's just a little fancier, doesn't add much.
2022-11-07 14:13:01 +01:00
Louis Gesbert
429911024c Add parseable line-column info to error messages
a quick fix for now, ideally we want an option for editor-friendly output.
But for now this is a very cheap way to at least have clickable error messages
which are a big time-saver.
2022-11-07 14:03:38 +01:00
Louis Gesbert
3e004551fc Callable scopes: fixes following review 2022-11-03 15:18:51 +01:00
Louis Gesbert
6e2c3eee4d Fix the regression on badly tagged scope variable error message
it actually simplifies the typer a little to not care about this specific error,
which is better handled in desugared_to_scope already.
2022-10-25 14:50:49 +02:00
Louis Gesbert
ddd7ce9a4e Error handling for invalid scope calls 2022-10-25 11:38:22 +02:00
Louis Gesbert
73173285e4 Scope calls: proper handling of context vars
Also proper error messages on bad scope input specifications.

* Still needs more tests
2022-10-25 11:30:45 +02:00
Louis Gesbert
41d6d3cbe9 Make scopes directly callable
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...)
2022-10-21 17:17:26 +02:00
Louis Gesbert
19d0c35961 Printer: less verbose variables printing
Pass along a bindlib context to allow the variable names to be altered only when
disambiguation is needed. Partial fix to #240 (doesn't affect the backends, only
the printer for the intermediate ASTs).

This also has the benefit of making the output of the tests much more stable.
2022-10-19 14:40:58 +02:00
Louis Gesbert
7bcafa4ead Fix bug in bindlib use
This is a workaround (but corresponds to what was executed before) and means
that we re-explore all exprs to look for free variables.

The proper fix will be to store boxed_exprs inside scopes instead.
2022-10-07 18:00:59 +02:00
Louis Gesbert
6c8a9f830c Compute the Dcalc stage when running catala Typecheck
it has some important resolution/sanity checks
2022-10-07 17:41:27 +02:00
Louis Gesbert
6c0c2f073d Update test on i/o variable check
This is no longer detected by pure type-checking, as the check is done during
compilation to scope-lang, which now takes place afterwards.
2022-10-04 14:50:37 +02:00
Louis Gesbert
1b3a1f7219 Update test results
These are just variable renumberings, and type error message changes but still
pointing to the same information; the latter are slightly better in general,
pointing to actual expressions rather than scope declarations.
2022-10-04 14:50:37 +02:00
Louis Gesbert
609cc5cc9a Tests: add info on manually running a single test 2022-10-04 14:50:37 +02:00
Louis Gesbert
12d2833306 Fix cyclic type test
Make it type so that it's actually the cycle error that is raised
(now that expression typing is done earlier)
2022-10-04 14:50:37 +02:00
Louis Gesbert
d93b699a4c Forward types in the Expr.make_* constructors
Also add some safeguards against bad propagation of types (e.g. checking the
arrow type of functions upon application); partly disabled at the moment since
they don't pass yet but that'll be further work.
2022-10-04 14:50:37 +02:00
Louis Gesbert
3d73071012 Typing tests: reword test doc for clarity 2022-09-26 15:27:36 +02:00
Louis Gesbert
a41de29293 Improve typing error message on <any> array
- don't print variable id on type variables, there should be no ambiguity
- print "array" as "collection" to match the language
- print just "collection" for "'a collection", which makes sense english-wise
2022-09-26 14:29:15 +02:00
Louis Gesbert
abd5a4de96 Tests: cleanup remaining whitespace 2022-09-26 14:27:47 +02:00
Louis Gesbert
c18de3b980 Tweak the order in which typing is done 2022-09-26 14:11:25 +02:00
Louis Gesbert
76569bb1af Fix position on type error concerning sub-scope variable 2022-09-26 14:11:25 +02:00
Louis Gesbert
498429e4b7 Fix type-checking error getting delayed
The issue was coming from Bindlib: it stores variable bindings as closures, so
`Bindlib.box_apply f bx` actually delays the application of `f` until the term
is substituted or unboxed (likely long after we are out of the `try..with`
block).

The proposed fix is to make sure we run the wrapper outside of bindlib
applications, on explicitely unboxed terms.
2022-09-26 14:11:25 +02:00
Louis Gesbert
8bf6b5b821 Type arrow return types first 2022-09-26 14:11:25 +02:00
Louis Gesbert
2c3be946ec Keep type positions on the right-hand side upon unification of types
This should result in more predictable error messages. Right-hand is arbitrary,
but has been found empirically to give better results.
2022-09-26 14:11:25 +02:00
Louis Gesbert
43e4efeeb8 Some typing error tests improvements 2022-09-26 14:11:25 +02:00
Louis Gesbert
8c1696d0ff Inline tests: cleanup trailing whitespace 2022-09-23 16:56:21 +02:00
Louis Gesbert
fe6fabb1b0 Clerk tests: update README 2022-09-23 16:41:22 +02:00
Louis Gesbert
0c0ef1ae1a Add test return codes
Simply re-generated with 'make tests CLERK_OPTS=--reset'
2022-09-23 14:50:02 +02:00
Louis Gesbert
0ab7a0f9ce Turn all existing tests to inline tests
Done using
```bash
process() { FILE=$1; awk 'match($0, /^```catala-test *{ *id *= *"(.*)" *}/, a) {print "```catala-test-inline"; f="'"$(dirname $FILE)/output/$(basename $FILE)"'." a[1]; getline; print "$ " $0; while ((getline<f) > 0) print; next} {print}' $FILE >$FILE.new; mv $FILE.new $FILE; }
for f in tests/test_*/*/*.catala_* examples/**/*.catala_*; do process $f; git add $f; done
for d in $(find -name output -type d); do git rm -r $d; done
```
2022-09-23 14:45:10 +02:00
Louis Gesbert
1b97f55c00 Add a few tests on typing errors
the `err6` test also highlights that Typecheck errors get overly delayed
2022-09-15 17:28:05 +02:00
Aymeric Fromherz
2c5b3dd25e Add unit tests for extension of Z3 backend to non-bool EMatch nodes 2022-09-13 16:05:33 +02:00
Denis Merigoux
d7e219b0dd
Correct test output for proof mode 2022-09-06 14:10:32 +02:00
Denis Merigoux
a1e6d992a9
Fix test output 2022-09-05 10:48:05 +02:00
Raphaël Monat
d9cc2dbb43 Fix format in excepted test 2022-09-05 09:31:39 +02:00
Raphaël Monat
f60cfcc435 Merge branch 'master' of github.com:CatalaLang/catala into dates_calc_lib 2022-08-30 15:14:51 +02:00
Denis Merigoux
5bddde1c68
Fix documentation and test invocation 2022-08-30 13:48:20 +02:00
Louis Gesbert
01cc957b3b Used shared_ast for scopelang expressions 2022-08-26 11:31:14 +02:00
Louis Gesbert
576e0fb3ff Factorise AST printers
Note that there were significant differences between the two printers (see the test diff!). Overall the `dcalc` one seemed newer so that's what I took, with only the required additions from `lcalc` (exceptions, raise and catch)
2022-08-22 19:28:27 +02:00
Denis Merigoux
755b1212a2
Remove division durations 2022-08-19 15:21:29 +02:00
Denis Merigoux
9008a7f0e6
Improving French housing benefits (#314)
Follow-up of #287, #266 and #165.
Time spent
Pair programming sessions

Before 2022-07-11: 50h (50 h for each person of the pair programming duo)

Refactoring sessions

Before 2022-07-11: 24 h
2022-07-14: 3 h

Legal research sessions

Before 2022-07-11: 21,5 h

Testing and debugging

Before 2022-07-11: 13,5 h
2022-07-11: 3 h with Denis
2022-07-13: 2 h with Denis
2022-07-14: 1 h with Denis
2022-07-16: 2 h with Denis
2022-07-19: 2 h with Denis
2022-07-21: 2 h with Denis
2022-08-11: 6 h with Denis
2022-08-15: 4 h with Denis
2022-08-16: 2 h with Denis

UI and form

2022-08-09: 8 h with Denis
2022-08-10: 8 h with Denis
2022-08-15: 2 h with Denis
2022-08-16: 2 h with Denis
2022-08-17: 6 h with Denis
2022-08-18: 4 h with Denis
2022-08-19 14:57:48 +02:00
Louis Gesbert
d9c1426c66 Add test for precedence of local variabes vs. local scopes
Ref. #317
2022-08-19 11:08:28 +02:00
Denis Merigoux
437be673ce
Merge branch 'master' into aides_logement 2022-08-16 14:25:06 +02:00
Denis Merigoux
2ae0efa5dd
Fix subtle bug with the default false value for conditions 2022-08-15 16:47:36 +02:00
Denis Merigoux
1aeb47effd
Fix uncaught type error 2022-08-15 16:20:31 +02:00
Louis Gesbert
0b0e774d1c More factorisation, in particular for variables 2022-08-12 17:18:06 +02:00
Louis Gesbert
f35f18b295 Add local 'let in' bindings 2022-08-09 12:17:31 +02:00
Louis Gesbert
a569589193 Small improvements to the Python and OCaml pretty-printers 2022-08-04 20:43:39 +02:00
Denis Merigoux
a3cf272c71 Restore test 2022-07-29 18:42:14 +02:00
Denis Merigoux
974c2b8d58 Fix bug in Python backend 2022-07-28 15:02:43 +02:00
Louis Gesbert
6d41818e0a Change syntax for set membership predicate
Before: `ELEMENT in SET`; now: `SET contains ELEMENT`

Using the `in` keyword was causing conflicts and blocking #203.
Current proposal has `contient` for the French syntax, and is untranslated (`contains`) for Polish.
2022-07-27 14:34:58 +02:00
Emile Rolley
d9045499c0 refactor(french_law/ocaml): refactor the api_web.ml 2022-07-22 17:01:33 +02:00
Denis Merigoux
b7c468bd1e
Fix faulty unboxing 2022-07-22 16:18:55 +02:00
Denis Merigoux
85144c35fb Simplify default tree encoding 2022-07-22 12:31:02 +02:00
Denis Merigoux
3895743f20 Cleaned code for generating exception graph, now correct and fully general
Missing some encoding optimizations
2022-07-22 12:25:41 +02:00
Denis Merigoux
109c7dec31 Create failing test 2022-07-22 12:11:34 +02:00
Denis Merigoux
6d224e1a41
Merge pull request #272 from AltGr/types-everywhere
Annotate the ASTs with type information everywhere
2022-07-20 11:07:17 +02:00
Emile Rolley
4991350b58 feat(backend/ocaml): disambiguate OCaml record names derived from Catala struct 2022-07-12 16:12:18 +02:00
Louis Gesbert
4726d00df8 Adjust test results
Nothing shocking here:
- division by zero now reported on the application rather than the
operator
- renumbering of printed bindlib variables
- some whitespace changes
2022-07-11 17:43:59 +02:00
Louis Gesbert
d2a182043b Update doc for handling tests 2022-07-11 16:03:47 +02:00
Louis Gesbert
2e5050481d Register all existing tests through the new engine
I removed the '.out' extension for now to preserve the test output file names and avoid a million file renames.

This makes the patch easier to read, and we can do the rename easily in another patch afterwards, without mixing with semantic changes.

(beautiful script àlarrache:
```bash
for f in */*/output/*; do
  target_base=${f##*/}
  target_base=${target_base%%.*}
  echo $f | awk -F. '{
    f=$1"."$2; if ($4 == "") { mode=$3; id=$3 } else { scope="-s "$3; mode=$4; id=$3"."$4}
    printf "\n```catala-test {id=\"%s\"}\ncatala %s %s\n```\n",id,mode,scope;
  }' >> $(dirname $f)/../${target_base}.*; done
```
2022-07-08 17:06:20 +02:00
Denis Merigoux
a78f649377
Add negative test 2022-07-08 14:16:02 +02:00
Denis Merigoux
bdbf202a8d
Minimal implementation of https://github.com/CatalaLang/catala/issues/192#issuecomment-1178750411 2022-07-08 14:10:25 +02:00
Denis Merigoux
8782168632
Added test for month multiplication 2022-06-01 15:20:32 +02:00
kescher
db9eec3b9f add support for duration multiplication
Signed-off-by: Jonathan Protzenko <protz@microsoft.com>
2022-05-31 11:17:38 -07:00
Denis Merigoux
853d92ad34
Fix test encoding 2022-05-31 16:24:37 +02:00
Louis Gesbert
9ef8625df7 Compiler: support cumulative exceptions
Closes #208 (implementing Solution 1, without adding an explicit syntax)

Two exceptions or more, e.g. `(j1 |- c1)` and `(j2 |- c2)` such that `c1
= c2`, are collapsed by this transformation into `((j1 |- c1) | j2 |-
c2)`, introducing an arbitrary precedence that avoids the conflict.

The transormation is not applied if any exceptions apply to the subterms
themselves: while these exceptions could be merged, that would turn more
conflicts into arbitrary outcomes than wanted.
2022-05-30 14:22:34 +02:00
Louis Gesbert
cd70e16ea3 Compiler: simplify EDefault term at construction
This allows to match on their structure further on.
2022-05-25 18:36:07 +02:00
Louis Gesbert
05e3205fc9 Parser: priority tweaks
- makes sums and mults left-associative instead of right-associative (see the
  change in the tests!)
- uses higher priority for unary operators
2022-05-11 19:26:34 +02:00
Denis Merigoux
09e7ba762d
Rename test 2022-05-05 17:34:48 +02:00
Denis Merigoux
080e60c25d
Fixes money cents parsing 2022-05-05 16:50:33 +02:00
Denis Merigoux
c7b84ca2d0
Merge pull request #244 from CatalaLang/c_backend
Bringing structure to the Lcalc AST
2022-05-05 14:22:26 +02:00
Denis Merigoux
78e8275d5e
Adds a decimal rounding operator 2022-04-29 21:18:15 +02:00
Denis Merigoux
1c86c8298b
Fix decimal parsing 2022-04-22 14:26:28 +02:00
Denis Merigoux
171c3966f5
Pass some make flags to Clerk 2022-04-14 11:47:18 +02:00
Romain PRIMET
eafab30809 fix typo 2022-04-07 22:43:05 +02:00
Denis Merigoux
3f49824150
Merge branch 'master' into c_backend 2022-04-04 18:02:33 +02:00
Denis Merigoux
31e8f37a43
Sort VCs by alphabetical order 2022-04-04 17:51:41 +02:00
Denis Merigoux
84144c0a56
Tests now passing except for a few position and printing issues [skip ci] 2022-04-04 12:25:00 +02:00
Denis Merigoux
6fb924b7d4
Merge pull request #236 from CatalaLang/afromher_z3
[Z3 encoding] Add support for durations
2022-03-28 19:08:11 +02:00
Denis Merigoux
ce7e756af1
Nice error messages for empty structs and enums 2022-03-28 14:43:38 +02:00
Aymeric Fromherz
cca2e00d42 [Z3encoding] Add bad unit tests for duration 2022-03-24 17:27:03 +01:00
Aymeric Fromherz
55dd389819 [Z3encoding] Add good unit tests for duration 2022-03-24 17:23:31 +01:00
Aymeric Fromherz
cb36b9d72f [Z3backend] Bad unit tests for EInj node 2022-03-16 12:04:31 +01:00
Aymeric Fromherz
d758170cde [Z3backend] Good unit tests for EInj node 2022-03-16 12:03:24 +01:00
Aymeric Fromherz
bb57abf750 Negative tests for array length encoding 2022-03-16 11:23:36 +01:00
Aymeric Fromherz
123541dc34 Add positive test for array length 2022-03-16 11:21:54 +01:00
Denis Merigoux
5ce85b40b2
Added all packages to be installed 2022-03-07 12:02:03 +01:00
Denis Merigoux
23766e34a9
More negative tests 2022-03-07 11:55:26 +01:00
Denis Merigoux
f6de45416c
Cycle test 2022-03-06 17:34:51 +01:00
Denis Merigoux
94c1874500
Subscope test 2022-03-06 17:28:58 +01:00
Denis Merigoux
8167d7ee00
Simple tests 2022-03-06 17:13:40 +01:00
Denis Merigoux
eb7f00f56d
Syntax: parser and highlighting 2022-02-28 14:33:07 +01:00
Denis Merigoux
756e7cb9b2
Merge branch 'master' into alain_default-option 2022-02-24 16:41:35 +01:00
Aymeric Fromherz
f5a3a19a09 [Z3 encoding]: Add negative tests for rationals 2022-02-19 02:02:48 +01:00
Aymeric Fromherz
1dc1d6a3b8 Good test for rationals 2022-02-19 02:00:46 +01:00
Aymeric Fromherz
56e3720699 Add unit tests for TUnit 2022-02-17 18:42:22 +01:00
Denis Merigoux
69a7465339
Merge branch 'master' into alain_default-option 2022-02-14 12:09:11 +01:00
Denis Merigoux
a56d9f674a
visibility -> io 2022-02-14 10:17:41 +01:00
Denis Merigoux
e1dc36f1b1
Merge branch 'master' into io-qualifiers-112-part-2 2022-02-10 22:59:37 +01:00
Denis Merigoux
5004929a51
Fix #193 -- authored with @R1kM
Moved no model generation flag
Fixed bug for VC generation in the IfThenElse case
2022-02-10 16:49:01 +01:00
Denis Merigoux
e4be116ded
Add negative tests 2022-02-09 17:22:04 +01:00
Denis Merigoux
36bc25a3ce
Update assets 2022-02-09 16:09:28 +01:00
Denis Merigoux
a8733e6a61
Fix tests [skip ci] 2022-02-09 15:56:57 +01:00
Denis Merigoux
cb04ef3f9d
OnlyInput variables nore more thunked 2022-02-09 15:34:13 +01:00
Denis Merigoux
30061b8c86
Better encoding of inputs [skip ci] 2022-02-09 11:37:52 +01:00
Denis Merigoux
1c4a0bdd5d
Updated all examples with input/output decorations [skip ci] 2022-02-07 18:18:23 +01:00
Denis Merigoux
2263dd7dab
Update syntax highlighting and test suite [skip ci] 2022-02-07 12:04:48 +01:00
Denis Merigoux
f4200bb638
Dcalc encoding good, missing error messages for bad cases 2022-02-06 18:52:18 +01:00
Denis Merigoux
72274057cd
Better Dcalc printing 2022-02-06 18:25:37 +01:00
Denis Merigoux
6601585b77
First test passing, awaiting rest of features
(subscopes, etc.)
2022-02-05 00:04:19 +01:00
Denis Merigoux
45fe92be62
Update syntax highlighting 2022-02-04 23:10:29 +01:00
Denis Merigoux
5962b23f93
Restore CI 2022-02-04 15:45:27 +01:00
Denis Merigoux
97f8875a39
Merge branch 'master' into alain_default-option 2022-02-04 15:35:52 +01:00
Denis Merigoux
11d4a34783
Better printing, tests, fix parser ommission 2022-02-04 15:10:47 +01:00
Denis Merigoux
d8c120bf97
Propagate visibility down, missing handling in scope_to_dcalc 2022-02-04 14:41:22 +01:00
Denis Merigoux
73ce2f142f
Fixed last bug around rule refactoring 2022-01-31 13:55:25 +01:00
Denis Merigoux
13b476d0a1
[skip ci] reorganized desugared to scope encoding, broke some invariants
WIP: fixed some bugs and provided documentations but one thing missing
2022-01-28 17:31:31 +01:00
Denis Merigoux
5e253ba321
Disabling exact counterexamples values from CI testing because of randomness 2022-01-26 16:24:09 +01:00
Aymeric Fromherz
661b30f638 Add bad tests for date_get_year 2022-01-17 15:05:06 +01:00
Aymeric Fromherz
c7fd00702a Fix good get year test + reset [skip ci] 2022-01-17 15:04:05 +01:00
Aymeric Fromherz
cf63e4f3d3 Restore pretty-printing of enum model [skip ci] 2022-01-14 21:10:34 +01:00
Aymeric Fromherz
271d20dcaf todo outputs for bad struct tests [skip ci] 2022-01-14 20:42:06 +01:00
Aymeric Fromherz
ede73501d6 Add bad struct tests [skip ci] 2022-01-14 20:41:03 +01:00
Aymeric Fromherz
8b1c2d0891 reset test [skip ci] 2022-01-14 20:38:11 +01:00
Aymeric Fromherz
9684e14b1b reset tests [skip ci] 2022-01-14 19:24:20 +01:00
Aymeric Fromherz
a128a188ee reset [skip ci] 2022-01-14 19:05:58 +01:00
Aymeric Fromherz
9727acc788 more tests [skip ci] 2022-01-14 19:04:23 +01:00
Aymeric Fromherz
38b4912161 Reset test [skip ci] 2022-01-14 19:02:59 +01:00
Aymeric Fromherz
867fc46515 Add more complex enum test [skip ci] 2022-01-14 19:01:23 +01:00
Aymeric Fromherz
cc026e35b3 Add negative tests for enums 2022-01-14 18:37:32 +01:00
Aymeric Fromherz
d7563c229e Reset test [skip ci] 2022-01-14 18:34:58 +01:00
Denis Merigoux
08591fd178
Add link to demo 2022-01-14 16:52:30 +01:00
Aymeric Fromherz
7ca0ca4012 Reset bad dates examples with expected outputs [skip ci] 2022-01-14 02:09:20 +01:00
Aymeric Fromherz
59e36d2750 Reset good dates simple test [skip ci] 2022-01-14 01:56:07 +01:00
Aymeric Fromherz
c8be75ca75 Z3encoding: Add bad tests related to dates [skip ci] 2022-01-13 20:28:28 +01:00
Aymeric Fromherz
52f33aa1ae Fix good date example [skip ci] 2022-01-13 20:25:16 +01:00
Aymeric Fromherz
a6c88b103f Reset bad money tests [skip ci] 2022-01-13 20:13:12 +01:00
Aymeric Fromherz
28935c689d Reset good money test [skip ci] 2022-01-13 20:12:28 +01:00