Commit graph

345 commits

Author SHA1 Message Date
Ayaz Hafiz
16d12a51c2
Add Eq to the standard library 2022-10-12 16:37:48 -05:00
Ayaz
83b64c4fb3
Merge pull request #4209 from roc-lang/impl-tag-discriminant
Derive `Hash` implementations for tag unions
2022-10-10 22:23:05 -05:00
Richard Feldman
3d5728d82c
Merge pull request #4257 from roc-lang/i4246
Correctly check mutual functional recursion between opaque types
2022-10-08 16:20:27 -07:00
Ayaz
51c687df54
Merge branch 'main' into i4150
Signed-off-by: Ayaz <20735482+ayazhafiz@users.noreply.github.com>
2022-10-08 16:08:35 -05:00
Ayaz Hafiz
d9863cbbaa
Correctly check mutual functional recursion between opaque types
The mutual-recursion checks does not admit types that are not function
types; because Roc is strict, only functional values can be involved in
mutual recursion. However, this check was exercised by checking the head
constructor of a type, which is not the correct way to do it. Aliases
and opaque types may in fact be function types as well, so we must chase
their actual contents.

Closes #4246
2022-10-08 10:09:55 -05:00
Ayaz Hafiz
912cebc33d
Add tests for inferring char ranged number 2022-10-05 17:28:01 -05:00
Ayaz Hafiz
178b634266
Treat single quote literals as ranged numbers for inference purposes 2022-10-05 17:28:00 -05:00
Ayaz Hafiz
06e5110aa5
Unification of multiple tag-functions 2022-10-05 17:25:11 -05:00
Ayaz Hafiz
61cf8e53e6
Have FunctionOrTagUnion include multiple possible tags 2022-10-05 17:24:52 -05:00
Ayaz Hafiz
2517695ce4
Fix deriving of hash ability for recursive tag unions 2022-10-05 12:01:02 -05:00
Ayaz Hafiz
5b833e57b5
Support derivation of Hash for Str and List 2022-10-04 14:09:40 -05:00
Ayaz Hafiz
f68cb3b0ed
Flip order of hash signature 2022-10-04 12:14:07 -05:00
Ayaz Hafiz
e9efc95425
Obligation checking for the Hash ability
This implements type-level checks that types can and cannot implement
the `Hash` ability.

Part of #4195
2022-10-04 10:51:14 -05:00
Ayaz Hafiz
eadbc0912a
Update the compiler to be aware of Hash 2022-10-04 10:22:22 -05:00
dependabot[bot]
49dd5af13d
Bump insta from 1.19.0 to 1.20.0
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.19.0 to 1.20.0.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.19.0...1.20.0)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-26 07:14:24 +00:00
Ayaz Hafiz
06bef34829
Import Decode by default in all modules 2022-09-21 12:29:07 -05:00
Ayaz Hafiz
b7b0af0d45
Update solve tests 2022-09-21 12:29:06 -05:00
Ayaz Hafiz
454f3634fd
Import all types from Encode by default 2022-09-21 12:29:06 -05:00
Ayaz
211c297230
Merge pull request #4041 from KilianVounckx/opaque-bool
Opaque bool
2022-09-21 11:15:41 -05:00
Folkert de Vries
cc202a4cf9
Merge pull request #4082 from roc-lang/update-cli-platform-unreachables
Support unification with uninhabited tag variants in more places
2022-09-21 12:18:38 +02:00
kilianv
9717747a54
Update tests
not all tests pass yet. Will look at them with Ayaz.
2022-09-20 14:42:03 -05:00
Ayaz Hafiz
412c73c54c
Add test cases for uninhabited variant collapsing with destructure patterns
Closes #4080
2022-09-20 14:22:40 -05:00
Ayaz Hafiz
f96c825aa4
Allow uninhabited type extension to happen on either unification side 2022-09-20 14:20:47 -05:00
Ayaz Hafiz
b0598ef817
Simplify unification with uninhabited tags to happen anytime tags are uninhabited
I believe this is safe! No need to gate it behind a mode.
2022-09-20 14:13:55 -05:00
Ayaz Hafiz
1799d6ed0e
Construct exhaustiveness branches with condition, not branch, variable
Previously we would construct the shapes of unions used in the pattern
tree for exhaustiveness checking using the type of the branch patterns,
rather than the type of the condition variable. Clearly we want to
always use the condition variable, otherwise some branches will be
seen as exhaustive, when they are not!

To do this, we now index into the condition variable while refying the
patterns to build the tree for exhaustiveness checking.

Closes #4068
2022-09-19 13:37:59 -05:00
Ayaz Hafiz
be853b65c5
Support unification of extension types with uninhabited branches 2022-09-19 10:32:39 -05:00
Ayaz Hafiz
ac752adc7c
Check in some more work 2022-09-16 16:09:21 -05:00
dependabot[bot]
0079048944
Bump bumpalo from 3.10.0 to 3.11.0
Bumps [bumpalo](https://github.com/fitzgen/bumpalo) from 3.10.0 to 3.11.0.
- [Release notes](https://github.com/fitzgen/bumpalo/releases)
- [Changelog](https://github.com/fitzgen/bumpalo/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fitzgen/bumpalo/compare/3.10.0...3.11.0)

---
updated-dependencies:
- dependency-name: bumpalo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 21:08:56 +00:00
dependabot[bot]
d1c406812f
Bump pretty_assertions from 1.2.1 to 1.3.0
Bumps [pretty_assertions](https://github.com/rust-pretty-assertions/rust-pretty-assertions) from 1.2.1 to 1.3.0.
- [Release notes](https://github.com/rust-pretty-assertions/rust-pretty-assertions/releases)
- [Changelog](https://github.com/rust-pretty-assertions/rust-pretty-assertions/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-pretty-assertions/rust-pretty-assertions/compare/v1.2.1...v1.3.0)

---
updated-dependencies:
- dependency-name: pretty_assertions
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-09-12 05:28:00 +00:00
Jan Van Bruggen
aec2baefe3
Merge pull request #3997 from roc-lang/lint_markdown
Lint all markdown files once, guided by markdown-cli2
2022-09-09 09:27:31 -06:00
Jan Van Bruggen
8bbfd68621
Add language to all fenced code blocks
See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md040
2022-09-09 01:12:31 -06:00
Jan Van Bruggen
051059e151
Replace tabs with spaces
See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md010
2022-09-09 01:12:30 -06:00
Jan Van Bruggen
3902668ce5
Add angle brackets to bare URLs
See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md034
2022-09-09 01:12:30 -06:00
Jan Van Bruggen
3219178003
Ensure only one h1 per .md file
See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md025
2022-09-07 23:27:18 -06:00
Ayaz Hafiz
c2452ff751
Lose rigidity of annotated optional fields before generalization
We have this idea of "rigid optional" fields to annotate record fields
that must necessarily be optional. That avoids the admission of programs
we cannot faithfully compile, like

```
f : {a: Str, b ? U64}
f = {a: "b", b: 1}
```

We want to lose the rigidity restriction when a generalized symbol is
used as at a specialized site; for example it should be possible to call
`f : {x ? Str} -> {}` with both `{}` and `{x : Str}`, neither of which
have a rigidly optional field unless they were to be annotated.

Prior to this commit we would loosen the rigidity restriction upon
specialization of a generalized type at a use site. However, what we
really want to do is apply the loosening during calculation of
generalization. The reason is that otherwise, we must make types that
would be ground (like `{x ? Str} -> {}`) generalized just for the sake
of the optional field annotation. But since the rigidity constraint is
irrelevant after an annotated body has been checked, we can loosen the
rigidity restriction then, which conveniently happens to coincide with
the generalization calculation.

Closes #3955
2022-09-06 17:44:04 -05:00
Folkert de Vries
3dbf6cc99b
Merge pull request #3859 from roc-lang/dependabot/cargo/insta-1.19.0
Bump insta from 1.18.2 to 1.19.0
2022-08-30 12:14:24 +02:00
Ayaz Hafiz
a1d8f8392a
Include RigidOptional as optional field 2022-08-23 10:39:51 -05:00
Ayaz Hafiz
e77e53f37b
Enable optional record field underivable error 2022-08-23 10:39:51 -05:00
Ayaz Hafiz
55fe1df995
Add more context to derivability errors when they happen 2022-08-23 10:39:50 -05:00
Ayaz Hafiz
d2b9cc056f
Record with optionally-typed fields cannot be derived for decoding 2022-08-23 10:38:30 -05:00
Ayaz Hafiz
6255332cee
Promote flex vars to flex-able in obligation checking 2022-08-22 17:05:56 -05:00
dependabot[bot]
0f31f0f07a
Bump insta from 1.18.2 to 1.19.0
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.18.2 to 1.19.0.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.18.2...1.19.0)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-22 05:22:53 +00:00
Ayaz Hafiz
641169854e
Ignore unused branch patterns in tests 2022-08-20 10:05:22 -05:00
Richard Feldman
0ba5b3cfc6
Merge pull request #3711 from roc-lang/record-decoding
Record decoding and their derivers
2022-08-15 22:06:34 -04:00
Ayaz Hafiz
60ed17155c
Check in gen test for record decoding! 2022-08-15 11:11:36 -05:00
dependabot[bot]
4c6ad52c47
Bump indoc from 1.0.6 to 1.0.7
Bumps [indoc](https://github.com/dtolnay/indoc) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/dtolnay/indoc/releases)
- [Commits](https://github.com/dtolnay/indoc/compare/1.0.6...1.0.7)

---
updated-dependencies:
- dependency-name: indoc
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-15 13:18:18 +00:00
Ayaz
11f0de21e1
Merge pull request #3781 from roc-lang/dependabot/cargo/insta-1.18.2
Bump insta from 1.15.0 to 1.18.2
2022-08-13 13:36:32 -07:00
Ayaz Hafiz
6bcd682dde
Support captures between mutually recursive closures 2022-08-13 10:25:18 -07:00
Ayaz Hafiz
e97ce32b88
Fixup transient closure captures during canonicalization
Closure captures can be transient, but previously, we did not handle
that correctly. For example, in

```
x = ""
inner = \{} -> x
outer = \{} -> inner {}
```

`outer` captures `inner`, but `inner` captures `x`, and in the body of
`outer`, we would not construct the closure data for `inner` correctly
before calling it.

There are a couple ways around this.

1. Update mono to do something when we are passed the captured
   environment of a closure, rather than attempting to construct a
   call-by-name's captured environment before callign it.
2. Fix-up closures during canonicalization to remove captured closures
   that themselves capture, and replace them with their captures.

This patch does (2), since (1) is much more involved and is not likely
to bring a lot of wins. In general I think it's reasonable to expect
captured environments, even if transient, to be fairly shallow, so I
don't think this will produce very large closure environments.

Closes #2894
2022-08-13 10:25:17 -07:00
dependabot[bot]
7ab742dd1a
Bump insta from 1.15.0 to 1.18.2
Bumps [insta](https://github.com/mitsuhiko/insta) from 1.15.0 to 1.18.2.
- [Release notes](https://github.com/mitsuhiko/insta/releases)
- [Changelog](https://github.com/mitsuhiko/insta/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mitsuhiko/insta/compare/1.15.0...1.18.2)

---
updated-dependencies:
- dependency-name: insta
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-13 16:49:28 +00:00