Commit Graph

649 Commits

Author SHA1 Message Date
Ayaz Hafiz
a1c1dc1a9f
Ask rustc to please always inline 2022-04-13 08:49:27 -04:00
Ayaz Hafiz
0336b6ad27
Clippy 2022-04-12 19:02:58 -04:00
Ayaz Hafiz
67b5ab7fe7
Add test for when specialization types conflict 2022-04-12 19:01:36 -04:00
Ayaz Hafiz
cf1a6691dd
Fix solve tests 2022-04-12 18:54:12 -04:00
Ayaz Hafiz
d94556d807
Report overly general specializations 2022-04-12 18:52:49 -04:00
Ayaz Hafiz
16d0060824
Report errors for type errors in specializations outside of ability impl 2022-04-12 18:41:20 -04:00
Ayaz Hafiz
127d435ff2
Report incomplete ability implementations 2022-04-12 18:26:19 -04:00
Ayaz Hafiz
462f443956
Comment 2022-04-12 17:23:03 -04:00
Ayaz Hafiz
64b559073d
Clippy 2022-04-12 16:18:07 -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
Ayaz Hafiz
913d97cab1
Add needed imports 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
5f19410de6
Merge branch 'simplify-unused-defs' into builtins-in-roc 2022-03-21 23:45:09 +01:00
Folkert
38c2710fc5
intern common tag names 2022-03-20 15:30:47 +01:00
Folkert
6a9b08ed11
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc 2022-03-20 13:01:00 +01:00
hafiz
3f07afe3b5
Merge pull request #2750 from rtfeldman/delay-instantiating-aliases-fix-limitations
Delay instantiating aliases fix limitations
2022-03-19 20:41:14 -04:00
hafiz
418e71e95c
Merge pull request #2755 from rtfeldman/dense-let-constraints
Constraint gen tweaks
2022-03-19 20:39:55 -04:00
Folkert
7f92de69ab
some comments 2022-03-19 23:44:28 +01:00
Folkert
55d9dc745c
track if an alias is exposed 2022-03-19 17:10:29 +01:00
Richard Feldman
5f2054aeb6
Merge pull request #2754 from rtfeldman/remove-type-solvedtype-conversion
Remove Type/Subs -> SolvedType conversion
2022-03-19 10:48:42 -04:00
Folkert
5a15a121ff
remove Content -> SolvedType conversion 2022-03-19 12:26:21 +01:00
Folkert
21a51464f3
various small type-related changes 2022-03-18 22:35:12 +01:00
Folkert
4e1197165b
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc-delayed-alias 2022-03-18 21:25:52 +01:00
Folkert
a3b00fbf55
Merge branch 'explicit-closed-tag-record' into delay-instantiating-aliases 2022-03-17 20:34:52 +01:00
Folkert
f8a73e0baa
use unreachable! 2022-03-17 19:50:16 +01:00
Folkert
426bfe3ff1
implement solve crate 2022-03-17 19:31:54 +01:00
Folkert
c5fb4f2e47
rewrite and fix builtin alias instantiation 2022-03-16 22:10:04 +01:00
Folkert
7fd420bb95
optimize instantiation of builtins 2022-03-16 21:15:54 +01:00
Folkert
ad6fd18b05
optimizations for known aliases and identity substitutions 2022-03-16 18:33:53 +01:00
Folkert
b3dce7317d
hook up aliases 2022-03-15 22:23:40 +01:00
Folkert
7d8409f6a6
write Aliases implementation 2022-03-15 22:02:04 +01:00
Folkert
9059e09dca
thread through Aliases 2022-03-14 21:20:35 +01:00
Folkert
f9bd46ecb8
fake implementation of type_to_var for DelayedAlias 2022-03-14 20:22:38 +01:00
Folkert
00f3eaf2a1
thread through DelayedAlias 2022-03-14 19:47:19 +01:00
ayazhafiz
5670fe06cd Deal with destructuring tag unions behind opaques correctly
Closes #2702
2022-03-13 18:44:38 -05:00
Folkert
15ac77567a
make rigid variable introducion more obvious 2022-03-13 18:27:42 +01:00
Folkert
523032c6c9
more comments 2022-03-13 14:05:53 +01:00
Folkert
ed247c9da3
Merge remote-tracking branch 'origin/trunk' into type-checking-storage-subs 2022-03-13 13:43:00 +01:00
Folkert
eccb461b01
get fancy, store variable directly in the index 2022-03-13 01:59:28 +01:00
Folkert
b3d9f9c2de
use EitherIndex<Type, Variable> to halve number of types stored 2022-03-13 01:46:49 +01:00
Folkert
da03b0c2b3
add either_type_index_to_var 2022-03-13 01:45:23 +01:00
Folkert
e3e9215578
Merge remote-tracking branch 'origin/trunk' into type-checking-storage-subs 2022-03-12 14:10:43 +01:00
Folkert
6bb8bcb5a2
cleanup 2022-03-12 14:02:34 +01:00
Folkert
d9c3a7ddd9
get rid of unneeded field on SolvedModule 2022-03-12 14:00:51 +01:00
Folkert
c64f768abe
more comments 2022-03-12 13:52:13 +01:00
Folkert
01b810266b
test cleanup 2022-03-11 22:15:36 +01:00
Folkert
364bc81dc4
stop making solved types for non-builtins 2022-03-11 21:08:24 +01:00
Brendan Hansknecht
d681062c63 add Num.toNat 2022-03-11 11:17:42 -08:00
Folkert
30e7d94c95
clarify old constraint gen is now just for the builtins 2022-03-11 19:25:42 +01:00
Folkert
aebb3a162e
it's alive! 2022-03-11 17:27:44 +01:00
Folkert
9054546d27
move things in place to go storage_subs -> subs 2022-03-11 10:49:22 +01:00
Folkert
28abf5b1b8
store exposed values as storage subs 2022-03-11 10:12:25 +01:00
Folkert
831a90e310
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc 2022-03-08 22:36:06 +01:00
Folkert de Vries
ce1839133b
Merge pull request #2661 from rtfeldman/i/2541
Report invalid extension types during canonicalization
2022-03-07 16:12:04 +01:00
ayazhafiz
47e4904075 Chase aliases when checking for valid extension types 2022-03-06 22:17:58 -05:00
Folkert
ba2f9ba779
Merge remote-tracking branch 'origin/trunk' into content-flattype-copy 2022-03-06 20:52:04 +01:00
Folkert de Vries
27f367ec23
Merge pull request #2656 from rtfeldman/type-to-var-tco
Optimize type_to_variable
2022-03-06 20:44:14 +01:00
Folkert
a9c8e2dc3e
copy instead of clone Content 2022-03-06 19:07:18 +01:00
hafiz
de9da2d8a5
Merge pull request #2657 from rtfeldman/i/2567
Register accessor closures when they are bound
2022-03-06 12:59:55 -05:00
Folkert
29bf4195a1
make FlatType Copy 2022-03-06 18:15:26 +01:00
Folkert
41e56519ef
prevent a subs lookup by reserving a Variable 2022-03-06 18:00:25 +01:00
Richard Feldman
2a6a197fdf
Merge pull request #2653 from rtfeldman/def-types-tweaks
Def types tweaks
2022-03-06 11:25:37 -05:00
Folkert
47a1e5f816
Merge branch 'type-to-var-tco' into builtins-in-roc 2022-03-06 17:00:57 +01: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
0f5c339b4f
and roc_result_to_var 2022-03-06 15:29:23 +01:00
Folkert
eec92204f1
optimize type_to_union_tags 2022-03-06 15:13:39 +01:00
Folkert
8b526e4f58
clippy 2022-03-06 14:54:19 +01:00
Folkert
592a5ace19
optimize recursive call 2022-03-06 14:14:47 +01:00
Folkert
a37a895016
optimize tag name cache 2022-03-06 14:11:33 +01:00
Folkert
04818292a8
Make type_to_variable manually tail-recursive
by using a work stack and reserving variables. fun stuff
2022-03-06 13:22:55 +01:00
Folkert
7ad55d67e2
Make type_to_variable manually tail-recursive
by using a work stack and reserving variables. fun stuff
2022-03-06 13:15:50 +01:00
Folkert
4806dc378f
add comment and assert back 2022-03-05 23:49:21 +01:00
Folkert
0351b9fce7
improvements to adjust_rank 2022-03-05 23:45:07 +01:00
Folkert
97d9027271
improve pool_to_rank_table 2022-03-05 23:44:57 +01:00
Folkert
3372d7184e
improvements to adjust_rank 2022-03-05 23:29:33 +01:00
Folkert
fd179c8b4e
improve pool_to_rank_table 2022-03-05 23:07:57 +01:00
Folkert
6009768991
Merge branch 'def-types-tweaks' into builtins-in-roc 2022-03-05 22:36:59 +01:00
Folkert
c7c9a90d65
restructure how def_types are stored in Constraints 2022-03-05 21:47:49 +01:00
Folkert
adf4ad22a5
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc 2022-03-05 20:55:15 +01:00
hafiz
cad02d878c
Merge pull request #2645 from rtfeldman/solve-fully-tail-recursive
make solve fully tail recursive
2022-03-05 14:35:39 -05:00
Folkert
1b66247303
renaming 2022-03-05 19:30:15 +01:00
Folkert
fc4212310f
Merge remote-tracking branch 'origin/trunk' into solve-fully-tail-recursive 2022-03-05 18:34:09 +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
d158702e1a
Merge remote-tracking branch 'origin/trunk' into take-scratchpad-bug 2022-03-05 02:15:46 +01:00
Folkert
8c321c1aa4
fix a bug with taking a scratchpad arena 2022-03-05 02:12:10 +01:00
Folkert
a79f6c6cdd
restructure and add comments 2022-03-05 01:29:21 +01:00
Folkert
c7d8ae6c79
make complex case tail-recursive 2022-03-05 01:02:27 +01:00
Folkert
3a1add6ce8
add LocalDefVarsVec::from_def_types 2022-03-05 00:53:27 +01:00
Folkert
41df04184e
make the simple case tail-recursive 2022-03-05 00:26:03 +01:00
Folkert
4ca9ea0b89
refactor After 2022-03-04 23:57:41 +01:00
Folkert
38d3d3169a
drop final suffixes 2022-03-02 21:30:38 +01:00
Folkert
546afc9661
drop soa suffix 2022-03-02 21:21:37 +01:00
Folkert
0eb98a4c59
move over constraint 2022-03-02 21:19:58 +01:00
Folkert
c52029c2d1
the debugging begins 2022-03-02 20:30:42 +01:00
Folkert
fe48bdf5b1
make solve that uses new constraint 2022-03-02 19:43:03 +01:00
Folkert
19d7f7ce09
make vars-by-symbol a vector 2022-03-01 21:51:25 +01:00
Folkert
8b457a56c5
reduce cloning of Env 2022-03-01 00:08:56 +01:00
Folkert
d3bbf6d504
struct of arrays! 2022-03-01 00:00:50 +01:00
Folkert
1ef9546391
use Vec instead of MutMap 2022-02-28 23:54:35 +01:00
Folkert
9d82f795b7
make it abstract 2022-02-28 23:43:58 +01:00
Folkert
751ae125a5
remove aliases from solve Env 2022-02-28 23:41:07 +01:00
Folkert
c18befeccf
short-circuit aliases 2022-02-28 23:37:33 +01:00
Folkert
bd31503855
Merge remote-tracking branch 'origin/trunk' into builtins-in-roc 2022-02-28 18:55:20 +01:00
ayazhafiz
01da425851 Simplify solve worklist substantially 2022-02-27 16:41:31 -05:00
Folkert
db1669154e
WIP 2022-02-27 21:53:56 +01:00
ayazhafiz
56d4dc3480 Transition solve to use a worklist rather than always recursing
This should unblock some of @folkertdev's work on transitioning builtins
to pure Roc code. It's not perfect yet (we still make some recursions),
but it's a step, and it should avoid recursing on `Let`
`ret_constraint`s, which caused stack overflows when they became really
long before.
2022-02-27 15:51:19 -05:00
ayazhafiz
07b1829732 Improve error reporting for patterns not matching opaques 2022-02-27 00:11:11 -05:00
ayazhafiz
059c324268 Error reporting for type mismatches involving opaques 2022-02-27 00:10:12 -05:00
ayazhafiz
b6d7229525 Infer + checking tests for opaques 2022-02-27 00:10:12 -05:00
Folkert
65b1b3fcce
just before Num 2022-02-26 23:11:40 +01:00
Folkert
c0d3543d5a
make Str + Result work 2022-02-26 17:52:24 +01:00
hafiz
ca9ecbea52
Merge pull request #2533 from rtfeldman/abilities!
[WIP] Spike for abilities and friends
2022-02-21 23:18:40 -05:00
ayazhafiz
90de82e295 Validation of opaques during canonicalization 2022-02-21 18:25:19 -05:00
ayazhafiz
6b53692aac Canonicalize opaque types 2022-02-20 13:47:01 -05: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
0d241f3c3c Only expand ErrorType::Range's type range when range unification fails 2022-02-06 15:04:13 -05:00
ayazhafiz
680bf8e0b7 Treat rigids as flex vars when checking number range types 2022-02-06 15:04:12 -05:00
ayazhafiz
c5d918e68c Include floats in bounds for unspecified numbers 2022-02-06 15:04:12 -05:00
ayazhafiz
8dc92ccd97 Second pass 2022-02-06 15:04:12 -05:00
ayazhafiz
5e0d90ac53 First pass 2022-02-06 15:04:12 -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
ayazhafiz
d10eb0f9a3 Fix Apply usage 2022-01-31 23:00:37 -05:00
Folkert
afd11e1cb1 move target -> roc_target 2022-01-26 23:33:29 +01: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