Commit graph

189 commits

Author SHA1 Message Date
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
Jared Ramirez
d69b9173fc Also store f64 for things like pattern comparisons, etc 2021-08-18 17:18:13 -07:00
Folkert
894ef2b7b2 Merge remote-tracking branch 'origin/trunk' into alias-nominal-equality 2021-07-30 23:34:16 +02:00
Folkert
e0648d348d new formatting 2021-07-30 17:13:50 +02:00
Folkert
13b05e54e8 Merge remote-tracking branch 'origin/clippy-1.54' into alias-nominal-equality 2021-07-30 14:25:50 +02:00
Folkert
899cbeabd7 fix extra ampersands 2021-07-29 17:32:08 +02:00
Folkert
4cefbec5c7 store lambda set in alias types 2021-07-28 15:26:25 +02:00
Richard Feldman
53ccef0506 nightly clippy
I was on nightly for benchmarks, and these all seem reasonable.
2021-06-18 15:21:11 -04:00
Folkert
700e7d9686 parse expect 2021-04-22 23:00:44 +02:00
Folkert
ebd6ee3f14 optimize cycleentry generation 2021-04-10 22:00:45 +02:00
Folkert
112e97c4a2 improve circular definition error reporting 2021-04-10 21:39:20 +02:00
Folkert
ce98da9d04 remove Nested from Def 2021-03-21 21:14:32 +01:00
Folkert
7731ab38d1 update tests 2021-01-21 22:41:47 +01:00
Folkert
b8c0c85395 tell me what function has no implementation 2021-01-20 16:29:19 +01:00
Folkert
4dd7ea1356 add some failing tests 2021-01-17 00:38:30 +01:00
rvcas
127c4e1bcc feat: add inner var to IntLiteral and FloatLiteral 2020-12-29 20:52:54 -05:00
Anton-4
b085469602 Replaced large_enum_variant explanation with link to issue #800 2020-12-14 16:09:16 +01:00
Folkert
815b942f29 cleanup 2020-11-13 01:59:09 +01:00
Folkert
55b26277ca properly sort recursive definitions 2020-11-12 00:32:45 +01:00
Folkert
33f65caedd alias referenced by another alias is not unused! 2020-11-09 22:22:00 +01:00
Folkert
4868c0bd25 fix problem with patterns and optional record fields 2020-11-09 01:04:40 +01:00
Sébastien Besnier
f4c1af0f19 test_can pass 2020-11-08 13:43:11 +01:00
Sébastien Besnier
014131dabe handle AnnotatedBody everywhere. It compiles now! 2020-11-08 13:43:11 +01:00
Richard Feldman
2f2e67059b
Merge branch 'trunk' into fuzz 2020-11-01 08:57:19 -05:00
Folkert
8b3b677439 remove aliases from Let and LetCon 2020-10-31 15:27:24 +01:00
Brendan Hansknecht
d00189530a Add fuzzing to the parser.
As part of this, todos and panics where moved outside of this module
to elsewhere when they would cause fuzzing to fail.
2020-10-30 22:04:54 -07:00
Folkert
93a1baad1d use only references (no Vec) in canonical AST 2020-10-26 01:03:33 +01:00