Commit graph

219 commits

Author SHA1 Message Date
Ayaz Hafiz
25b3aa7ca7
Typed body specializations solve 2022-04-13 10:42:46 -04:00
Ayaz Hafiz
cf1a6691dd
Fix solve tests 2022-04-12 18:54:12 -04:00
Ayaz Hafiz
15a040ec87
Basic type inference and solving for abilities
Note that is still pretty limited. We only permit opaque types to
implement abilities, abilities cannot have type arguments, and also no
other functions may depend on abilities
2022-04-12 16:18:07 -04:00
Nikita Mounier
0f0e9bdf14
Fix test in solve_expr.rs 2022-04-12 12:12:29 +00:00
Richard Feldman
d81228df80
cargo fmt 2022-04-11 13:17:46 -04:00
Nikita Mounier
1df1b4bc84
Fix typo. 2022-04-11 12:34:23 +00:00
Nikita Mounier
8206f345c7 Merge remote-tracking branch 'origin/trunk' into div-no-result 2022-04-11 11:45:06 +00:00
Nikita Mounier
4ecf2a8c24 Modify division behaviour to panic when dividing by 0, and add divChecked, divFloorChecked and divCeilingChecked` for safe alternatives which return a Result, mimicking the previous behaviour. 2022-04-11 11:23:33 +00:00
Folkert
52b58ecdf3
don't write to (temp) file in solve tests 2022-04-10 16:22:35 +02:00
Folkert
9d966d439f
fix solve tests 2022-04-09 12:29:49 +02:00
Folkert
1d0f9e9192
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc 2022-04-08 15:47:11 +02:00
Richard Feldman
8322ed95ed
Merge pull request #2806 from rtfeldman/toF32
Num.toF32/toF64 for LLVM backend
2022-04-08 08:28:07 -04:00
Ayaz Hafiz
17b3c7d8ee
Generate type variables when there are lots
Closes #2797
2022-04-07 17:49:48 -04:00
Richard Feldman
cd00a98636
Add toF32/64 and checked versions 2022-04-07 16:13:57 -04:00
Richard Feldman
bd623d65bc
Formatting whitespace 2022-04-07 16:13:57 -04:00
Ayaz Hafiz
163c6b39d6
Unify type alias "real variables"
Turns out that we can't always assume that a successful unification of
type alias type variables means that those aliases had the same real
type from the start. Because type variables may contain unbound type
variables and grow during their unification (for example,
`[InvalidNumStr]a ~ [ListWasEmpty]b` unify to give `[InvalidNumStr,
ListWasEmpty]`), the real type may grow as well.

For this reason, continue to explicitly unify alias real types for now.
We can get away with not having to do so when the type variable
unification causes no changes to the unification tree at all, but we
don't have a great way to detect that right now (maybe snapshots?)

Closes #2583
2022-04-05 11:21:52 -04:00
Folkert
aefb536bc4
Merge branch 'add-load-internal' into builtins-in-roc 2022-03-23 17:35:49 +01:00
Folkert
311e464b70
add load_internal 2022-03-23 15:18:22 +01:00
Folkert
ac19213fa4
stop using builtins/std 2022-03-23 14:49:38 +01:00
Folkert
b4d677ae5f
Merge branch 'simplify-stdlib-use' into builtins-in-roc 2022-03-22 20:13:12 +01:00
Folkert
d8fa2b8d92
stop passing stdlib (use lazy_static) 2022-03-22 19:53:02 +01:00
Folkert
4e1197165b
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc-delayed-alias 2022-03-18 21:25:52 +01:00
ayazhafiz
5670fe06cd Deal with destructuring tag unions behind opaques correctly
Closes #2702
2022-03-13 18:44:38 -05:00
Folkert
e3e9215578
Merge remote-tracking branch 'origin/trunk' into type-checking-storage-subs 2022-03-12 14:10:43 +01:00
Folkert
01b810266b
test cleanup 2022-03-11 22:15:36 +01:00
Brendan Hansknecht
d681062c63 add Num.toNat 2022-03-11 11:17:42 -08:00
Folkert
831a90e310
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc 2022-03-08 22:36:06 +01:00
ayazhafiz
47e4904075 Chase aliases when checking for valid extension types 2022-03-06 22:17:58 -05:00
ayazhafiz
3bff99b0a2 Register accessor closures when they are bound
Previously we only registered record accessor closures in anonymous
contexts, where we assume they must already be specialized based on the
surrounding contexts. This is not true in general since one might bind
an accessor to a name.

Closes #2567
2022-03-06 10:53:12 -05:00
Folkert
adf4ad22a5
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc 2022-03-05 20:55:15 +01:00
Folkert
80956061dd
fix formatting bug in type pretty-print 2022-03-05 15:03:59 +01:00
Folkert
6370a80c62
make sure lambda sets within aliases are in IntroducedVariables 2022-03-05 14:29:34 +01:00
Folkert
241dc5783e
remove VariablesIter, it was unused 2022-03-05 01:37:23 +01:00
Folkert
db06c10b5f
be smarter 2022-03-04 23:02:10 +01:00
Folkert
bd31503855
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc 2022-02-28 18:55:20 +01:00
Folkert
db1669154e
WIP 2022-02-27 21:53:56 +01:00
ayazhafiz
b6d7229525 Infer + checking tests for opaques 2022-02-27 00:10:12 -05:00
Folkert
c0d3543d5a
make Str + Result work 2022-02-26 17:52:24 +01:00
ayazhafiz
d90915a8cd Implement Num.to* builtins
Just wrap over Num.intCast
2022-02-19 11:28:41 -05:00
ayazhafiz
909fae5b6c Generalize recursion variables properly
Closes #2379
Closes #2481
2022-02-18 00:07:38 -05:00
Folkert
04adbe75ca fix test compilation 2022-02-14 21:09:51 +01:00
ayazhafiz
8c0e39211d Instantiate recursive aliases to their smallest closures
Now, when we have two aliases like

```
T a : [ A, B (U a) ]
U a : [ C, D (T a) ]
```

during the first pass, we simply canonicalize them but add neither to
the scope. This means that `T` will not be instantiated in the
definition of `U`. Only in the second pass, during correction, do we
instantiate both aliases **independently**:

```
T a : [ A, B [ C, D (T a) ] ]
U a : [ C, D [ A, B (U a) ] ]
```

and now we can mark each recursive, individually:

```
T a : [ A, B [ C, D <rec1> ] ] as <rec1>
U a : [ C, D [ A, B <rec2> ] ] as <rec2>
```

This means that the surface types shown to users might be a bit larger,
but it has the benefit that everything needed to understand a layout of
a type in later passes is stored on the type directly, and we don't need
to keep alias mappings.

Since we sort by connected components, this should be complete.

Closes #2458
2022-02-11 08:43:33 -05:00
ayazhafiz
df8113ce32 Typecheck numeric suffixes in patterns 2022-02-01 23:35:14 -05:00
ayazhafiz
e03592930f Typecheck numeric literals with suffixes in expressions
Part of #2350
2022-02-01 22:49:50 -05:00
Folkert
b9c318e9fb update the tests 2022-01-26 15:59:21 +01:00
Jan Van Bruggen
591477e77b Add most remaining Num.min/max* builtins
This skips `min/maxU128`, as they require a subtle change
to the `I128`-centric implementation of `Int`s.
2022-01-17 15:26:23 -07:00
Jan Van Bruggen
d7e2be306f WIP: Add Num.minI128 builtin (TODOs remain) 2022-01-15 17:49:15 -07:00
Joshua Warner
a3c6bfce43 Mark infer_union_def_position as a test (followup to #2305) 2022-01-03 20:11:06 -08:00
ayazhafiz
8e7ca57458 Close tag unions that are in the left hand side of an assignment 2021-12-30 19:51:14 -06:00
ayazhafiz
fda6c70835 Mark patterns in lambda argument position as having a presence constraint
Closes #2299
2021-12-30 18:21:28 -06:00