Commit graph

606 commits

Author SHA1 Message Date
Ayaz Hafiz
8431b27282
Remove redundant parameter in from_raw_named
The captures niche is already accounted for by the lambda name, so we
don't need that as an extra param.
2022-12-27 10:30:07 -06:00
Ayaz Hafiz
e89f5ad6e5
Mark a couple functions as crate-exposed 2022-12-27 10:28:00 -06:00
Ayaz Hafiz
0b57d2f74f
Remove unneeded import 2022-12-27 10:27:19 -06:00
Ayaz Hafiz
198417c183
Remove ProcLayout::from_raw 2022-12-27 10:25:43 -06:00
Ayaz Hafiz
7a6e68861c
Account for non-capturing functions in larger lambda sets passed to HOLLs
Previously, if the lambda set passed to a HOLL contained any function
that captured, we would assume that the specialization of the HOLL we
should make for each function in the lambda set that we dispatch to
should capture.

This is not right. Instead, we should specialize for each lambda in the
set passed to the HOLL. The present patch enforces that, making sure
that for each lambda in the set, we compute the exact proc layout needed
to call the lambda, based on the captures of the specific lambda in the
set, rather than looking at the set entirely.
2022-12-27 10:22:18 -06:00
Ayaz Hafiz
bb0493918e
Update more usages of from_raw 2022-12-27 09:54:18 -06:00
Ayaz Hafiz
38920b98fa
Debug missing lambda names 2022-12-27 09:54:12 -06:00
Ayaz Hafiz
ccd68b70e1
Do not associate top-level accessor thunks as closures
Leftover follow-up to #4645
2022-12-27 09:49:51 -06:00
Ayaz Hafiz
fe58a0591b
Migrate some more uses of from_raw 2022-12-27 09:27:29 -06:00
Ayaz Hafiz
54bb258aac
Remove stale uniqueness inference comment 2022-12-27 09:26:08 -06:00
Ayaz Hafiz
1e847efbfe
Correctly choose specialized shapes for anonymous closures 2022-12-27 09:18:41 -06:00
Ayaz Hafiz
593344f5c5
Determine the proc layout based on captures of an individual lambda
Previously, we determined whether a closure argument should be added to
the proc layout of a compiled function by checking whether the lambda
set was material at all. But, the extension for a single function should
be added if and only if the function itself captures.
2022-12-27 09:15:21 -06:00
Ayaz Hafiz
877714ff91
We prefer slices 2022-12-25 16:56:00 -06:00
Ayaz Hafiz
a8693e6102
Order list-min-size tests in descending order
Some of the head-constructor tests we generate can be supersets of other tests.
Edges must be ordered so that more general tests always happen after their
specialized variants.

For example, patterns

  [1, ..] -> ...
  [2, 1, ..] -> ...

may generate the edges

  ListLen(>=1) -> <rest>
  ListLen(>=2) -> <rest>

but evaluated in exactly this order, the second edge is never reachable.
The necessary ordering is

  ListLen(>=2) -> <rest>
  ListLen(>=1) -> <rest>

Closes #4732
2022-12-25 16:55:58 -06:00
Ayaz Hafiz
a295e7ac3d
Allow any int in switch condition layout 2022-12-25 16:55:37 -06:00
Folkert de Vries
4022b44ff9
Merge pull request #4798 from JTeeuwissen/main
Replace DeclarationToIndex elements with a hash map.
2022-12-22 17:19:37 +01:00
J.Teeuwissen
1caafbc131
Feedback 2022-12-22 15:42:26 +01:00
J.Teeuwissen
5229edd742
Use hash instead of binary search 2022-12-22 14:08:41 +01:00
Folkert
4ef541395a
remove dbg lowlevel 2022-12-22 02:45:09 +01:00
Folkert
f76df8a356
make dbg transparent to refcounting 2022-12-22 01:03:03 +01:00
J Teeuwissen
dc65298f9d
Merge branch 'roc-lang:main' into main 2022-12-20 10:19:35 +01:00
Joshua Warner
174f7d5e4d
Fix bug in unifying records
This was leading us to have an infinitely-recursive type, which eventually causes layout to stack-overflow

Fixes #4739
2022-12-17 11:37:19 -08:00
Folkert de Vries
f550f049db
Merge pull request #4768 from roc-lang/expects-store-specialized-variable
Support using dbg/expect in polymorphic functions
2022-12-16 00:10:40 +01:00
Richard Feldman
e9e82ddc08
Merge pull request #4766 from roc-lang/remove-f128
remove F128
2022-12-15 17:59:48 -05:00
Ayaz Hafiz
4315a36e90
Refine imported ZAT/function compilation 2022-12-14 17:13:59 -06:00
Ayaz Hafiz
02eec1f60c
Simplify the model of handling imported/unloaded symbol specializations 2022-12-14 17:13:58 -06:00
Ayaz Hafiz
b8aa8df100
Make sure to resolve lambda sets for imported top-levels correctly
Part of #4733
2022-12-14 17:13:43 -06:00
Ayaz Hafiz
a96225e92e
Store specialized variable for use in dbg as fake symbol in lowlevel call 2022-12-14 17:00:37 -06:00
Ayaz Hafiz
fe90355265
Store specialized variables of expect lookups in expect frames 2022-12-14 17:00:36 -06:00
Ayaz Hafiz
16209ef866
Store specialized lookup variables in expects 2022-12-14 16:59:05 -06:00
Ayaz Hafiz
9d5f2aa138
Store specialized var of lookups in storage subs 2022-12-14 16:55:14 -06:00
Ayaz Hafiz
66c5e1292e
Thread expectations through in phase result structs
And provide expectation subs when expectations should be compiled. This
will be useful for getting the specialized type of an expect lookup when
it's available.
2022-12-14 16:55:14 -06:00
Folkert
d287eafa3a
remove F128 2022-12-14 23:28:38 +01:00
Folkert de Vries
6f2e14cf18
Merge pull request #4765 from roc-lang/expects-store-layout-in-lookaside
Remove layouts from the mono AST for expects, and add regtest for #4749
2022-12-14 23:22:03 +01:00
Ayaz Hafiz
a5ecded934
Don't collect layouts in mono of expects anymore 2022-12-14 14:12:57 -06:00
Ayaz Hafiz
1962f2045e
Remove layouts from the mono AST for expects
This actually isn't needed, because the backends must lookup the layout
from the environment anyway. So it's enough to lookup the symbol and
find its layout, there is no need to additionally store it.
2022-12-14 14:10:02 -06:00
Ayaz Hafiz
f2ffda6d05
Revert "Add a LayoutBuffer to store layouts aside and thread it through"
This reverts commit 3d73e33b49.
2022-12-14 14:05:56 -06:00
Ayaz Hafiz
897b69b072
Revert "Store layouts in a layout-buffer for expects"
This reverts commit bba6e36a18.
2022-12-14 14:05:46 -06:00
Ayaz Hafiz
bba6e36a18
Store layouts in a layout-buffer for expects 2022-12-14 14:05:28 -06:00
Ayaz Hafiz
3d73e33b49
Add a LayoutBuffer to store layouts aside and thread it through 2022-12-14 13:48:58 -06:00
J.Teeuwissen
e3dcaa2141
typo 2022-12-14 14:02:09 +01:00
Ayaz Hafiz
00ff6dcad7
Print similar-layout procs when borrow fails to find one 2022-12-12 14:13:07 -06:00
Folkert
a72556b927
refactor entry point 2022-12-09 15:10:25 +01:00
Ayaz Hafiz
759127660d
Spread list tests can never touch exact-sized bounds tests
When compiling a pattern match like

```
[] -> ..
[_] -> ..
[_, ..] -> ..
```

to a decision tree, we must make sure that the last test (len >= 1)
does not touch the branch reached by the second test (len == 1). It is
enough to ban (len >=) tests from ever touching exact-sized list
patterns, because a spread test (len >=) can never reach an exact-sized
test.

On the other hand, an exact-sized test can reach a spread pattern,
because in

```
[_, _] -> ..
[..] -> ..
```

the last branch generates tests for patterns `[]` and `[_]`, and we would
like those patterns to be covered by the spread test (len >= 0)!

Closes #4685
2022-12-05 13:45:35 -06:00
Ayaz Hafiz
d660016b53
Clippy 2022-12-03 23:43:47 -06:00
Ayaz Hafiz
01dea13b49
Pretty print symbols 2022-12-03 22:33:45 -06:00
Ayaz Hafiz
b0300e4e90
Fix bug in resolving layout 2022-12-03 22:18:15 -06:00
Ayaz Hafiz
7b21936d4f
Add mono checker to tests 2022-12-03 22:10:37 -06:00
Ayaz Hafiz
6e72307736
Format problems reported by the IR checker 2022-12-03 21:35:01 -06:00
Ayaz Hafiz
a84aebf2d3
Implement a type checker for the mono IR 2022-12-03 18:24:03 -06:00