Commit graph

265 commits

Author SHA1 Message Date
ayazhafiz
787c8ee3a5 s/occurence/occurrence/g 2022-03-14 17:50:55 -05:00
ayazhafiz
3da34fc843 Report unbound type variables in aliases, opaques
Closes #2726
2022-03-14 17:42:45 -05:00
Folkert
8bc31e82c3
try to keep type and value symbols separate 2022-03-13 16:50:32 +01:00
ayazhafiz
d7abc3897b Parse abilities 2022-03-12 21:29:06 -06:00
ayazhafiz
6a71358431 Get rid of more clones when resolving recursive aliases and use fast ImMap 2022-03-11 14:59:19 -06:00
Folkert
fc5e09a9e3
use Vec instead of ImSet 2022-03-11 09:52:44 +01:00
ayazhafiz
0692caf7ba Consolidate Accessor data 2022-03-06 11:07:31 -05:00
Folkert
0285a1b0ea
cleanup 2022-03-05 16:41:29 +01:00
Folkert
cd203d20a3
also remove clones for Body 2022-03-05 16:12:19 +01:00
Folkert
b421df2a28
transform TypedDef to use fewer clones 2022-03-05 15:50:00 +01:00
Folkert
5e48577d29
remove clones in most cases in can/def 2022-03-05 15:32:55 +01:00
Folkert
7c83e940bd
leave a TODO 2022-03-05 13:55:30 +01:00
Folkert
d7eee71402
track lambda set variables; only use annotation variables in annotations... 2022-03-05 13:47:01 +01:00
Folkert
d5bba1a779
use vec instead of set 2022-03-02 15:01:19 +01:00
Folkert
edd2120535
reorder operations to remove clones 2022-03-02 14:57:03 +01:00
Folkert
b6fd034ddf
remove clones 2022-03-02 14:54:25 +01:00
Folkert
ef5a81f731
make reference mut 2022-03-02 14:52:48 +01:00
Folkert
4643148470
refactor 2022-03-02 14:51:00 +01:00
Folkert
96584cb98a
Revert "optimize def sorting"
This reverts commit 5a0562c7f1.
2022-03-02 14:49:48 +01:00
Folkert
5a0562c7f1
optimize def sorting 2022-03-01 21:44:44 +01:00
ayazhafiz
86aa0df661 Add constraint generation for opaque types 2022-02-27 00:10:11 -05:00
Brendan Hansknecht
f7c0e2ef19 Merge remote-tracking branch 'origin/trunk' into single-quote-literal 2022-02-24 10:13:39 -08: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
fa24e51593 Parse opaque types 2022-02-19 18:38:31 -05:00
ayazhafiz
8ce81e4607 AliasHeader -> TypeHeader 2022-02-19 17:51:56 -05:00
Folkert
637360fad5
clippy 2022-02-19 16:50:42 +01:00
ayazhafiz
e946b972f7 Only recursive tag unions are relevant in illegal cycles 2022-02-12 20:41:19 -05:00
ayazhafiz
55769caad6 Redundant clone 2022-02-11 08:52:37 -05:00
ayazhafiz
c71854d5a4 Remove opt_rec_var 2022-02-11 08:51:08 -05: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
c064c50036 Catch illegal alias cycles more strictly
Part of #2458
2022-02-10 22:12:33 -05:00
ayazhafiz
13552b11a6 Check self- and mutually-recursive aliases in the same pass 2022-02-10 08:15:48 -05:00
ayazhafiz
320827167f Parse number literal width suffixes
Supports [u,i][8,16,32,64,128] and [nat,dec]

Part of #2350
2022-02-01 22:48:48 -05:00
ayazhafiz
a9ed4ce4ce Removing references 2022-01-31 22:58:15 -05:00
ayazhafiz
4e942b3e5d Make nested datatypes into errors
I was hoping to add nested datatypes into the language, but it turns out
doing so is quite tricky and not all that useful with Roc's current
compilation model. Basically every implementation strategy I could think
of ended up requiring a uniform representation for the data layout
(or some ugly workaround). Furhermore it increased the complexity of the
checker/mono IR generator a little bit - basically, we must always pass
around the alias definitions of nested datatypes and instantiate them
at usage sites, rather than being able to unroll aliases as we currently
do during canonicalization.

So, especially because we don't support polymorphic recursion anyway, I
think it may be better to simply disallow any kind of nested datatypes
in the language. In any case, Stephanie Weirich [seems to think nested
datatypes are not needed](https://www.cis.upenn.edu/~plclub/blog/2020-12-04-nested-datatypes/).

Closes #2293
2022-01-31 22:58:01 -05:00
ayazhafiz
0eede1cd86 Generate unique symbols for shadowing identifiers
This code has a shadowing error:

```
b = False
f = \b -> b
f b
```

but prior to this commit, the compiler would hit an internal error
during monomorphization and not even get to report the error. The reason
was that when we entered the closure `\b -> b`, we would try to
introduce the identifier `b` to the scope, see that it shadows an
existing identifier, and not insert the identifier. But this meant that
when checking the body of `\b -> b`, we would think that we captured the
value `b` in the outer scope, but that's incorrect!

The present patch fixes the issue by generating new symbols for
shadowing identifiers, so deeper scopes pick up the correct reference.
This also means in the future we may be able to compile and execute code
with shadows, even though it will still be an error.

Closes #2343
2022-01-23 12:35:31 -05:00
ayazhafiz
48a3e871e8 Report self-recursive aliases at their declaration site, not in usages
Closes #2380
2022-01-22 14:26:32 -05:00
ayazhafiz
966198a6e7 Coalesce inline and normal alias headers
Unifies `As` annotations and `Alias` defs to use a common struct for
defining alias header information, i.e. the name and type variables of
the alias.
2021-12-26 09:37:56 -06:00
Folkert
a5957d9982 sort aliases before adding them to scope 2021-12-24 21:14:29 +01:00
Folkert
40e57142c4 add symbol creation helper 2021-12-24 15:16:27 +01:00
Joshua Warner
22e2545fd6 format 2021-12-22 20:46:42 -08:00
Joshua Warner
f19220473a Rename Located -> Loc 2021-12-22 19:18:22 -08:00
Chelsea Troy
6cf755ad8d Resolve a bunnnch of merge conflicts 2021-11-29 23:14:29 -06:00
Folkert
5632e3159d remove im dependency where not needed 2021-11-10 16:00:22 +01:00
Anton-4
69f6ffadab
Merge branch 'trunk' into deps 2021-11-06 18:07:34 +01:00
Kevin Sjöberg
f6d055dc62 Correct minor spelling mistakes 2021-11-06 15:29:08 +01:00
Brendan Hansknecht
d49ac68bcc Update dep with major version changes 2021-11-05 19:19:37 -07:00
Folkert
a15183a7d1 refactor 2021-11-03 14:09:04 +01:00
Eric Correia
8272ea876f Get it all to compile! 2021-10-02 13:48:07 -04:00