Commit graph

121 commits

Author SHA1 Message Date
Chelsea Troy
6cf755ad8d Resolve a bunnnch of merge conflicts 2021-11-29 23:14:29 -06:00
ayazhafiz
5bfc52cd3b Remove Sugar enum and inline single variant into CalledVia 2021-11-18 21:23:41 -05:00
ayazhafiz
8b7217847d Rename additional stale roc_module::operator refs and format 2021-11-18 20:20:33 -05:00
ayazhafiz
8a60162a1e Rename roc_module::operator -> roc_module::called_via
A bit of a nit, but this file is now more general than just keeping
track of operator methods.
2021-11-18 20:20:33 -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
Joshua Warner
d63405d824 Make Expr::List use a Collection 2021-11-13 07:38:11 -08:00
Joshua Warner
a4ca6a31a6 Use Collection in Expr::Record and related places 2021-11-13 07:36:05 -08:00
Folkert
5632e3159d remove im dependency where not needed 2021-11-10 16:00:22 +01:00
Kevin Sjöberg
f6d055dc62 Correct minor spelling mistakes 2021-11-06 15:29:08 +01: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
Jared Ramirez
adabf70132 [WIP] Update can & pattern to store numbers as validated strs 2021-08-16 16:16:10 -07:00
Richard Feldman
267836226c s/CodePoint/CodePt/g 2021-08-07 21:46:20 -04:00
Folkert
d4896d3ed2 remove inlinable_string dependency 2021-08-03 21:24:19 +02:00
Folkert
899cbeabd7 fix extra ampersands 2021-07-29 17:32:08 +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
Folkert
e81087f913 Merge remote-tracking branch 'origin/trunk' into specialize-lowlevel 2021-05-24 15:17:28 +02:00
Folkert
ffa680ddbc in apply, zeroargumenttag becomes normal tag again 2021-05-24 14:33:32 +02:00
tarjei
0ee15f15ee Unify FunctionOrTagUnion with regular tags and functions 2021-05-23 23:14:17 +02: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
ed7906ccbb fix canonicalization 2021-04-23 09:24:11 +02:00
Folkert
700e7d9686 parse expect 2021-04-22 23:00:44 +02:00
Folkert
46ab922dd1 throw error in canonicalization 2021-04-11 22:19:00 +02:00
Folkert
28ba645121 parse underscores in expressions 2021-04-11 21:02:31 +02:00
Folkert
0bd05f3ecf remove second macro def 2021-03-30 21:23:06 +02:00
Folkert
197835b6ed remove nested in expr 2021-03-21 20:56:18 +01:00
Folkert
19f05c9db8 remove old code 2021-03-21 20:55:07 +01:00
Folkert
1871697b0f remove BinOp variant 2021-03-20 23:01:12 +01:00
Folkert
d5ec66244f use new binops 2021-03-20 21:19:10 +01:00
Folkert
e0c211081a remove update field from normal Record constructor 2021-03-20 16:49:14 +01:00
Folkert
60265b5d2a add dedicated RecordUpdate tag to parse ast 2021-03-20 16:06:07 +01:00
Folkert
0e7106280c bump allocate precedence conflict 2021-03-20 15:59:06 +01:00
Folkert
9208000316 only store start position for PrecedenceConflict 2021-03-20 15:34:08 +01:00
Folkert
d22acb521e use record for PrecedenceConflict 2021-03-20 15:07:15 +01:00
Folkert
9d10b060da clippy 2021-03-17 21:19:26 +01:00
Eric Henry
4d046abefa builtin maxI128 initial 2021-03-09 12:47:42 -05:00
Folkert
e2d08b8f78 make backpassing an expr 2021-03-06 16:05:18 +01:00
Folkert
e395d18e16 bunch of stuff 2021-02-28 23:36:27 +01:00
Folkert
4eea0aff7a refactor parse AST to allow multiple if branches 2021-02-25 14:34:58 +01:00
rvcas
b34436e5cb Merge branch 'trunk' into int_a_float_a 2021-01-04 09:53:45 -05:00
Folkert
754521c4c3 all the clippy fixes 2021-01-01 00:40:41 +01:00
rvcas
9dbcfb7a97 Merge branch 'temp_numbers' into int_a_float_a 2020-12-30 19:59:20 -05:00
Jared Ramirez
48f964adf4 Add percision variable in fp/integer eq constraints 2020-12-28 16:22:34 -06:00
Sébastien Besnier
4e9387cbda fix compile issues 2020-12-28 21:17:27 +01:00
Folkert
8b289f3398 simple literals in editor ast 2020-12-15 17:00:08 +01:00
Folkert
66748d3a50 Merge remote-tracking branch 'origin/trunk' into editor-ir 2020-12-04 20:45:30 +01:00
Chadtech
767a348812 Record references in can/expr before evaluating to runtime error 2020-11-21 14:07:09 -05:00