Commit Graph

210 Commits

Author SHA1 Message Date
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
Anton-4
cf80f510cb change import for rust analyzer 2021-12-09 14:55:43 +01:00
ayazhafiz
d352d2cdf8 Revert "Include annotation type signatures in Expected struct"
This reverts commit 6e4fd5f06a1ae6138659b0073b4e2b375a499588.

This idea didn't work out because cloning the type and storing it on a
variable still resulted in the solver trying to uify the variable with
the type. When there were errors, which there certainly would be if we
tried to unify the variable with a structure that had nested flex/rigid
vars, the nested flex/rigid vars would inherit those errors, and the
program wouldn't typecheck.

Since the motivation here was to expose the signature type to
`reporting` so that we could modify it with suggestions, we should
instead pass that information along in something analogous to the
`Expected` struct.
2021-11-25 13:24:42 -05:00
ayazhafiz
ee34e79790 Include annotation type signatures in Expected struct
To provide better error messages and suggestions related to changing
type annotations, we now pass annotation type signatures all the way
down through the constraint solver. At constraint generation we
associate the type signature with a unique variable, and during error
reporting, we pull out an `ErrorType` corresponding to the original type
signature, by looking up the unique variable. This gives us two nice
things:

1. It means we don't have to pass the original, AST-like type
   annotation, which can be quite large, to everyone who looks at an
   expectation.
2. It gives us a translation from a `Type` to an `ErrorType` for free
   using the existing translation procedure in `roc_types::subs`,
   without having to create a new translation function.
2021-11-25 11:16:17 -05:00
ayazhafiz
62873fed81 Propogate original annotation region down in AnnotationSource
This makes it easier for error reporting to find the relevant
annotations that were part of a type error, and display that in the
error message presented to a user.
2021-11-25 11:15:31 -05:00
Folkert
3139e73cf9 optimize non-capturing closure type 2021-11-24 23:14:53 +01:00
Folkert
cb8e9acb92 special-case the closure tags 2021-11-24 21:14:58 +01:00
Richard Feldman
763809805b Drop unused alias info 2021-11-21 13:35:23 -05:00
ayazhafiz
30955a1eb8 Take syntactic sugar into account when reporting errors
Previously, a program like

```roc
word = "word"

if True then 1 else "\(word) is a word"
```

would report an error like

```
── TYPE MISMATCH ───────────────────────────────────────────────────────────────

This `if` has an `else` branch with a different type from its `then` branch:

3│  if True then 1 else "\(word) is a word"
                        ^^^^^^^^^^^^^^^^^^

This concat all produces:

    Str

but the `then` branch has the type:

    Num a

I need all branches in an `if` to have the same type!
```

but this is a little bit confusing, since the user shouldn't have to
know (or care) that string interpolations are equivalent to
concatenations under the current implementation.

Indeed we should make this fully transparent. We now word the error
message by taking into account the way calls are made. To support the
case shown above, we introduce the `CalledVia::Sugar` variant to
represent the fact that some calls may be the result of desugaring the
surface syntax.

This commit also demonstrates the usage of `CalledVia` to produce better
error messages where we use binary comparison operators like `<`. There
are more improvements we can make here for all `CalledVia` variants, but
this is a good starting point to demonstrate the usage of the new
procedure.

Closes #1714
2021-11-18 20:20:33 -05:00
Brendan Hansknecht
bddc08c977 Remove unused dependencies 2021-11-05 16:58:11 -07:00
Folkert
c5005d3dd1 Merge remote-tracking branch 'origin/trunk' into partialproc-by-reference 2021-11-03 15:32:39 +01:00
Folkert
a15183a7d1 refactor 2021-11-03 14:09:04 +01:00
Anton-4
a3fc724df3 removed unused maplit 2021-11-03 10:50:25 +01:00
Folkert
72194b87df fix typo 2021-09-24 21:58:25 +02:00
Folkert
23e8f6c687 only introduce rigid once! 2021-09-24 21:53:41 +02:00
Jared Ramirez
d69b9173fc Also store f64 for things like pattern comparisons, etc 2021-08-18 17:18:13 -07:00
Folkert
24ddc4b1e8 further optimizations 2021-08-13 13:25:36 +02:00
Folkert
894ef2b7b2 Merge remote-tracking branch 'origin/trunk' into alias-nominal-equality 2021-07-30 23:34:16 +02:00
Folkert
e805e63db6 typos 2021-07-30 16:54:22 +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
27c3d57e35 BROKEN 2021-07-29 17:22:25 +02:00
Folkert
4cefbec5c7 store lambda set in alias types 2021-07-28 15:26:25 +02:00
Folkert
ab7f4a70a1 remove list_var 2021-06-13 16:56:59 +02:00
Anton-4
314503cf7f fixed typos, added typos checking to CI 2021-06-05 20:02:54 +02:00
Richard Feldman
75ec2ecc7b
Merge pull request #1300 from rtfeldman/specialize-lowlevel
Polyvariant defunctionalization
2021-05-24 19:54:17 -04:00
Folkert
e81087f913 Merge remote-tracking branch 'origin/trunk' into specialize-lowlevel 2021-05-24 15:17:28 +02:00
Chadtech
ac7386fd27
Merge branch 'trunk' into hash-links 2021-05-24 09:14:52 -04:00
Folkert
fbb711b2ca Merge remote-tracking branch 'origin/trunk' into specialize-lowlevel 2021-05-24 15:11:40 +02:00
Folkert
f480919186 Merge remote-tracking branch 'origin/trunk' into no-arg-tag-union-func 2021-05-24 14:44:32 +02:00
Richard Feldman
c8665fa9b2
Merge branch 'trunk' into hash-links 2021-05-24 08:25:11 -04:00
Richard Feldman
a7518a675a Clean up some clippy warnings 2021-05-23 20:28:23 -04:00
tarjei
0ee15f15ee Unify FunctionOrTagUnion with regular tags and functions 2021-05-23 23:14:17 +02:00
Chadtech
12c0067348 Created scope and idents for module docs, but they appear to be empty when the doc links function tries to use them 2021-05-22 14:06:56 -04:00
Eric Henry
d34f984169 Starting to add no arg tag union 2021-05-17 17:07:19 -04:00
Folkert
a055fa3626 fix record accessors 2021-05-14 13:07:35 +02:00
Folkert
694a896d54 fix closure size inference 2021-05-09 16:07:52 +02:00
Folkert
86ffd430d7 introduce missing var 2021-05-05 21:35:39 +02:00
Folkert
b01377f868 save the stack 2021-04-23 11:49:32 +02:00
Folkert
903583f1d4 implement basic type error reporting 2021-04-23 09:41:49 +02:00
Folkert
4dd0ee6543 constrain expect 2021-04-23 09:36:12 +02:00
Richard Feldman
0a50b0b488 Change license to UPL-1.0
Closes https://github.com/rtfeldman/roc/issues/1199
2021-04-21 19:18:44 -04:00
Richard Feldman
792a18816a Update authors in Cargo.toml 2021-04-11 08:11:52 -04:00
Folkert
112e97c4a2 improve circular definition error reporting 2021-04-10 21:39:20 +02:00
Folkert
ff3f231155 remove Mode from stdlib 2021-04-01 21:42:38 +02:00
Folkert
ca04411523 fix tests/more uniq removal 2021-02-07 22:50:33 +01:00
Folkert
b80865778e literal patterns should have type Int a or Float a 2021-01-04 23:35:29 +01:00
Jared Ramirez
18d0141942 [WIP] Merge local changes with new branch 2020-12-31 13:08:50 -06:00
rvcas
1ab7dc54ad fix: gen_num tests 2020-12-30 21:18:08 -05:00