Fixes wrong typing for date subtraction operator (#559)

This commit is contained in:
Louis Gesbert 2024-01-16 12:04:27 +01:00 committed by GitHub
commit ca22e86c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View File

@ -435,7 +435,7 @@ let resolved_type ((op : resolved t), pos) =
| Sub_rat_rat -> [TRat; TRat], TRat
| Sub_mon_mon -> [TMoney; TMoney], TMoney
| Sub_dat_dat -> [TDate; TDate], TDuration
| Sub_dat_dur -> [TDate; TDuration], TDuration
| Sub_dat_dur -> [TDate; TDuration], TDate
| Sub_dur_dur -> [TDuration; TDuration], TDuration
| Mult_int_int -> [TInt; TInt], TInt
| Mult_rat_rat -> [TRat; TRat], TRat

View File

@ -0,0 +1,32 @@
```catala
declaration scope A:
output o content boolean
scope A:
definition o equals |2024-01-16| - 0 day <= 0 day
```
```catala-test-inline
$ catala Interpret -s A
[ERROR]
I don't know how to apply operator <= on types date and
duration
┌─⯈ tests/test_date/bad/substraction.catala_en:6.23-6.52:
└─┐
6 │ definition o equals |2024-01-16| - 0 day <= 0 day
│ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Type date coming from expression:
┌─⯈ tests/test_date/bad/substraction.catala_en:6.23-6.43:
└─┐
6 │ definition o equals |2024-01-16| - 0 day <= 0 day
│ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
Type duration coming from expression:
┌─⯈ tests/test_date/bad/substraction.catala_en:6.47-6.52:
└─┐
6 │ definition o equals |2024-01-16| - 0 day <= 0 day
│ ‾‾‾‾‾
#return code 123#
```