Commit graph

201 commits

Author SHA1 Message Date
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
rvcas
b510d6e94d fix: float error in repl 2020-12-30 20:47:11 -05:00
rvcas
c33cab57f2 Merge branch 'int-float-size-gen' into temp_numbers 2020-12-30 19:41:44 -05:00
rvcas
127c4e1bcc feat: add inner var to IntLiteral and FloatLiteral 2020-12-29 20:52:54 -05:00
Jared Ramirez
791a0e9404 Use precision in mono/ir to determine which number to generate 2020-12-29 09:33:55 -06:00
Jared Ramirez
48f964adf4 Add percision variable in fp/integer eq constraints 2020-12-28 16:22:34 -06:00
Folkert
caaf8e76c1 reintroduce multiple uniqueness vars in numbers 2020-12-22 20:13:54 +01:00
rvcas
b734b3de58 fix: should not check args.is_empty() 2020-12-22 09:05:58 -05:00
rvcas
e91fc2f1ff fix: clean up uniq and adjust PatternCategory for int type in constrain 2020-12-22 09:05:19 -05:00
rvcas
3ea4858eb5 fix(clippy): do not need let binding 2020-12-22 09:05:19 -05:00