Commit graph

20 commits

Author SHA1 Message Date
Folkert de Vries
816e390e36
Merge pull request #2057 from rtfeldman/reporting-cfg-windows
Use cfg to check if we're compiling for windows (in reporting)
2021-11-24 13:29:48 +01:00
Folkert
8ce195998a clean up comment 2021-11-23 20:05:11 +01:00
Folkert
e4ffe804ec remove lowercases from errortype alias 2021-11-22 20:26:50 +01:00
Folkert
2c20d79cb8 actually check if we're compiling (the compiler) for windows 2021-11-22 12:52:23 +01:00
ayazhafiz
5f230252ee Add reporting tests related underscore (infered) types 2021-11-21 23:06:48 -05:00
Brendan Hansknecht
8e834fba07 add error macros to roc_reporting 2021-11-20 18:49:33 -08:00
Folkert de Vries
71233fcfc1
Merge pull request #2012 from rtfeldman/i/1714
Take syntactic sugar into account when reporting errors
2021-11-19 10:26:24 +01:00
Folkert de Vries
a58c999d3e
Merge pull request #2008 from rtfeldman/improve-typo-suggestions
Minor improvements to "did you mean?" suggestions provided for missing identifiers
2021-11-19 10:24:52 +01:00
ayazhafiz
a985204d5c Simplify error message for string interpolation-related type mismatch 2021-11-18 21:32:07 -05:00
ayazhafiz
5bfc52cd3b Remove Sugar enum and inline single variant into CalledVia 2021-11-18 21:23:41 -05:00
ayazhafiz
4ef40be0f0 Remove unused variable refs 2021-11-18 20:20:33 -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
Folkert
9aca302c39 Merge remote-tracking branch 'origin/trunk' into deep-copy-var-to 2021-11-18 13:16:24 +01:00
ayazhafiz
d165052e64 Fix typo 2021-11-18 00:12:17 -05:00
ayazhafiz
22be349392 Remove redundant import 2021-11-17 22:48:41 -05:00
ayazhafiz
214b8a30a9 Suggest typo fixes for non-existing module values 2021-11-17 22:40:51 -05:00
ayazhafiz
c156f61b0f Suggest tags of primitive types when an ident is misspelled
With this change, mispellings of things like `true` and `false` will
include a hint to the user that they may want to use `True` and `False`,
respectively, instead.

There are a few ways to implement this, but exposing these common tags
(which compose builtin type aliases) seems the easiest, least expensive,
and doesn't break anything for now.
2021-11-17 22:40:51 -05:00
Callum Dunster
f972098e70 Move reporting module into root. 2021-11-16 19:58:21 +01:00