Commit Graph

2521 Commits

Author SHA1 Message Date
Louis Gesbert
05f4bb3537 Typing: simplify interface, split code in smaller functions 2022-10-04 14:50:37 +02:00
Louis Gesbert
51f79af13e Generalise the types to allow scopelang ASTs to be typed 2022-10-04 14:50:37 +02:00
Louis Gesbert
5a553149ff Makefile: ensure compiler is up-to-date when running tests 2022-10-04 14:50:37 +02:00
Louis Gesbert
0ad51b7aec Unify outermost types first in Typing.top_down
It doesn't actually change the error output much, but is more sound, and allowed
to fix a few quirks in the code.
2022-10-04 14:50:37 +02:00
Louis Gesbert
a8816eb9e4 Fix parser message that didn't make sense to me
I had the message appear after a `integer_to_decimal` not followed by `of`, but
might it happen in other cases ?
2022-10-04 14:50:37 +02:00
Louis Gesbert
af9f497ffb Implement typing of desugared/scopelang and lcalc terms
Note that this is incomplete in the case of desugared/scopelang because we only
have typing for expressions yet, and the scope/program structure is different.

The code allows passing an environment of types for scope/subscope variables in
order to resolve `ELocation` terms, but that's unused until we implement
scopelang typing at the scope level.
2022-10-04 14:50:37 +02:00
Louis Gesbert
b37a6c3703 Generalise the typer
This moves dcalc/typing.ml to shared_ast, and generalises the input type, but
without yet implementing the extra cases (these are all `assert false`): it's
just a first step.
2022-10-04 14:50:37 +02:00
Louis Gesbert
0bb9cce341 Simplify a few mark operations 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
Catala nix updated
0ddff5a50b update lock files 2022-10-03 14:18:24 +00:00
Denis Merigoux
b49d2e701e
build/fix: bump unionFind to last version (#343) 2022-10-03 15:35:47 +02:00
lIlIlIlIIIIlIIIllIIlIllIIllIII
55b8e9dffd
build/fix: bump unionFind to last version
Fixes #342
2022-10-03 11:29:59 +02:00
Louis Gesbert
c1078e1f82
Fix & improve typing messages (#341) 2022-09-26 15:36:45 +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
3ceb9ec80c Clerk: don't stop on 1st error on tests 2022-09-26 14:24:49 +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
Catala nix updated
e53f6b6087 update lock files 2022-09-26 00:28:43 +00:00
Louis Gesbert
84c1063509
Change the clerk tests to use inline output (#340) 2022-09-23 17:06:05 +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
005de24ee7 Inline tests: ensure proper escaping of output
and that the input is not truncated with --reset
2022-09-23 14:52:04 +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
b9c0453fc9 Clerk tests: add ability to have tests with inlined output
Reduces the number of files, and makes tracking and diffing tests much easier.
2022-09-23 13:50:56 +02:00
Denis Merigoux
19beb91262
gnu gedit syntax highlighting (#336) 2022-09-20 14:37:12 +02:00
Denis Merigoux
754174390b
Merge branch 'master' into yueli_master 2022-09-20 12:01:11 +02:00
Louis Gesbert
58f7e6bab8
Clerk: don't default to infinite ninja jobs (#337) 2022-09-20 11:51:37 +02:00
Louis Gesbert
6cb8ee7916 Clerk: don't default to infinite ninja jobs 2022-09-20 11:30:29 +02:00
Denis Merigoux
c7f07435fc
Moved doc around 2022-09-20 10:50:43 +02:00
Denis Merigoux
cc8c460fb3
Remove chinese language support as it is not yet supported by the compiler 2022-09-20 10:44:46 +02:00
YueLiPicasso
9c3b001f21 gnu gedit syntax highlighting 2022-09-20 16:15:46 +08:00
Denis Merigoux
f1d0831d86
LégiFrance<->Catala connector (#329) 2022-09-19 11:14:21 +02:00
Catala nix updated
fbd6b07372 update lock files 2022-09-19 00:26:12 +00: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
e7c3ef604e
Do not hardfail when pretty-printing unknown Z3 variables (#333)
This PR extends PR #331, by avoiding hard failures when pretty-printing
a Z3 model when generating a counterexample.
#331 added some Z3 variables to encode EMatch nodes that are only used
internally in the encoding, and do not correspond to any source
variable. When trying to retrieve the source variable corresponding to
this Z3 variable for pretty-printing purposes (stored in a map in the
context, called ctx.z3_vars), we thus had a hard OCaml failure due to a
Not_found exception.

This PR fixes this by ignoring internal variables during pretty-printing
of the counterexample. It also adds some unit tests for #331, although,
since counterexample generation is disabled in tests/, this specific
issue would not have been caught.

Fixes #332
2022-09-13 20:20:56 +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
Aymeric Fromherz
7f07274c1f Ignore unfound (i.e., internal) variables during Z3 model printing 2022-09-13 15:54:26 +02:00
Denis Merigoux
99627ff3dc
Better Z3 encoding of EMatch nodes (#331)
Now that #272 was merged and that type information is available at every
AST node, this PR improves the Z3 encoding of pattern matching in the
verification backend. To do so, it implements the second solution
presented in #241.

Fixes #241
2022-09-13 11:49:55 +02:00
Aymeric Fromherz
fee64d6f6f format 2022-09-13 10:37:30 +02:00
Aymeric Fromherz
b7854eb6f3 Z3Backend: Use type information inside AST node for match translation 2022-09-13 10:33:02 +02:00
Aymeric Fromherz
ea13981c5d Match annotation type in io.mli and in Z3 backend 2022-09-12 18:10:02 +02:00
Aymeric Fromherz
0592cdab2a Z3encoding: Use auxiliary variable for encoding type-generic EMatch 2022-09-12 17:52:55 +02:00
Catala nix updated
f6840f45b3 update lock files 2022-09-12 00:25:43 +00:00