Commit Graph

168 Commits

Author SHA1 Message Date
Ayaz Hafiz
b6ffd09adf
Update reporting tests 2022-10-12 16:37:50 -05:00
Ayaz Hafiz
0045c16b3e
Improve notes on underivable abilities 2022-10-12 16:37:49 -05:00
Ayaz Hafiz
b587bcf0c2
Implement obligation checking for the Eq ability
Every type can have `Eq.isEq` derived for it, as long as

- it does not transitively contain a function
- it does not transitively contain a floating point value
- it does not transitively contain an opaque type that does not support
  `Eq`
2022-10-12 16:37:49 -05:00
Christopher Duncan
d7cdcfc66b
Fix typo in error 2022-10-12 08:26:33 -04:00
Joshua Warner
ab4e03b05d Rename Lambda -> Closure for consistency 2022-10-08 11:05:05 -07:00
Ayaz Hafiz
9d91b9bc5a
Add reporting case for inferred char range type mismatch 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
a08b45263b
Merge branch 'main' into shift-signature
Signed-off-by: Ayaz <20735482+ayazhafiz@users.noreply.github.com>
2022-10-04 12:58:09 -05:00
Ayaz Hafiz
dea7661068
Have Num.shift*By functions shift by a U8
https://roc.zulipchat.com/#narrow/stream/231635-compiler-development/topic/casual.20conversation/near/302305020
2022-10-04 12:28:33 -05:00
Ayaz Hafiz
5c6856d1d6
Add reporting test 2022-10-04 11:10:11 -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
Ayaz
f145610be0
Merge pull request #4125 from roc-lang/fix-module-name-mismatches
Assorted QoL improvements to incorrect module importing
2022-10-04 06:37:19 -05:00
Ayaz Hafiz
cf5712620c
Suggest Bool.true and Bool.false where tag literals are used
Closes #4147
2022-10-03 17:36:27 -05:00
Ayaz Hafiz
581eeb5054
Improve invalid recursion error message quality 2022-10-03 13:30:43 -05:00
Ayaz Hafiz
92b754f292
Illegal self recursion on toplevel defs
Closes #4153
2022-10-03 13:14:56 -05:00
Ayaz Hafiz
fd4b20de58
Fix test
Closes #3385
2022-10-03 13:03:52 -05:00
Ayaz Hafiz
0cc9ea4b05
Detect and report module names that don't match what they are used as
Prior to this commit, if you had a module structure like

```
| - A.roc
| - Dep
    | - B.roc
```

where `B.roc` was defined as

```
interface B exposes [] imports []
```

and `A.roc` was defined as

```
interface A exposes [] imports [Dep.B]
```

The compiler would hang on you. The reason is that even though we expect
`B` to be named `Dep.B` relative to `A`, that would not be enforced.

With this patch, we now enforce such naming schemes - a module must have
the namespaced name it is referenced by. Currently, we determine the
expected namespaced name by looking at how transitive dependencies of the
root module reference the module. In the future, once we have a package
ecosystem and a solid idea of "package roots", we can use the "package
root" to determine how a module should be named.

Closes #4094
2022-10-02 21:38:03 -05:00
Ayaz Hafiz
c67be21636
Check that module names correspond to the paths they are defined in
Closes #3440
Closes #4050
2022-10-02 21:38:02 -05:00
Ayaz Hafiz
985da70343
Add tests to ignore for now 2022-09-30 13:40:34 -05:00
Ayaz Hafiz
92aa0912ea
Report unused imports in modules 2022-09-30 13:40:34 -05:00
Ayaz Hafiz
5dc51ce444
Add unnecessary import test cases 2022-09-30 13:40:34 -05:00
Ayaz Hafiz
5f117be306
Improve error message when shadowing builtin type
Closes #3109
2022-09-30 13:40:34 -05:00
Tim Whiting
ab000a5b49
Update error text
fix error text
2022-09-30 07:36:24 -06:00
Tim Whiting
f323fe6534
fix expression indentation error 2022-09-28 20:11:24 -06: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
1de37f042e
Update reporting tests 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
Ayaz
362dadc7e9
Merge pull request #4073 from roc-lang/i4068
Construct exhaustiveness branches with condition, not branch, variable
2022-09-20 17:03:33 -05:00
Ayaz Hafiz
c430939432
Fix reporting tests 2022-09-20 15:51:04 -05:00
Ayaz Hafiz
10dffe8691
Unused import 2022-09-20 14:42:09 -05:00
Ayaz Hafiz
3d4313efbf
Update reporting tests 2022-09-20 14:42:09 -05:00
kilianv
9a168ecba3
Change error reporting for bools 2022-09-20 14:42:02 -05:00
Richard Feldman
a237c5c0fb
Merge pull request #4071 from roc-lang/cli-program
Program.roc in CLI platform
2022-09-20 07:11:38 -07: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
0f0e414272
Improve error message for uninhabited patterns 2022-09-19 10:55:02 -05:00
Ayaz Hafiz
147636f42b
Base reported row numbers on original rows, not reified rows 2022-09-19 10:47:35 -05:00
Ayaz Hafiz
041b91e031
Add more test cases 2022-09-19 10:45:31 -05:00
Richard Feldman
88ab511687
Report canonicalization errors on opaque names 2022-09-19 09:20:51 -04:00
Ayaz Hafiz
ac752adc7c
Check in some more work 2022-09-16 16:09:21 -05:00
Ayaz Hafiz
6adb88beee
Report uninhabited branches as redundant 2022-09-16 15:55:46 -05:00
Ayaz Hafiz
1d7aef8c96
Don't include uninhabited constructors in exhaustiveness checking 2022-09-16 15:36:54 -05:00
Ayaz Hafiz
42633c1f96
Span body of last branch in exhaustiveness checking
Closes #4028
2022-09-13 16:24:59 -04: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
431455dd1b
Rephrase web/terminal-related "platform" to "environment" 2022-09-11 10:25:02 -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
d016d5eeb9
Refine message 2022-08-23 10:39:51 -05:00