Commit graph

189 commits

Author SHA1 Message Date
Agus Zubiaga
160dbee943
Nicer message for unhandled expr errors 2024-11-06 12:15:38 -03:00
Agus Zubiaga
f4c8492c1c
Report return syntax errors 2024-11-06 10:50:32 -03:00
Sam Mohr
66cc96edbb
Address PR comments from @ayazhafiz 2024-10-29 15:58:35 -07:00
Sam Mohr
a9cd6ac5fa
Fix tailcalling 2024-10-26 06:48:01 -07:00
JRI98
511308d4d3
Fix #6240 2024-10-22 12:04:48 +01:00
hrishisd
cb98c45e88
Remove deprecated string interpolation syntax 2024-10-08 16:31:22 -04:00
Nathan Kramer
be4e3b5983
Suggest link to tutorial's operator desugaring table 2024-09-30 18:14:35 +10:00
Anton-4
0a0bc897f6
add final expression tip 2024-09-26 20:17:35 +02:00
Sam Mohr
2da08be8ef
Remove old record builder syntax 2024-09-21 04:44:44 -07:00
Elias Mulhall
b515bfa77e
Use a shared env for desugaring and the rest of canonicalization
This refactor simplifies the desugar pass by reducing the number of
arguments threaded through each recursive function call.

- Add the module src string to `Env`.
- Add `line_info` to `Env` as a lazy-evaled function.
- Refactor desugar functions to take the `can::Env` struct in place of a
  number of params. This is mostly a find-and-replace, but in a few
  places `Vec::from_iter_in` was changed to `Vec::with_capacity_in`
  followed by a `for` loop in order to avoid lifetime issues.
- Remove unnecessary linter annotations for `clippy::too_many_arguments`
2024-09-05 20:13:48 -04:00
Elias Mulhall
f356f6f7a0
Do not display generated symbol names in error messages
When an error message reports on a symbol that was generated during
canonicalization, use text like "This value" instead of "This `123`
value". Generated symbols use the identifier index as the symbol name,
since valid Roc variables cannot begin with a number so there's no
chance of collision. We don't want to display generated symbols to the
user, so when building the error message we check if the symbol's name
starts with a digit.
2024-09-03 14:00:46 -04:00
Elias Mulhall
82d0566041
Use module scope instead of var store to generate idents in dbg desugar
Fix a bug in `dbg` expression desugaring by using the module scope to
generate unique identifiers instead of the variable store.

In the initial implementation of `dbg` expressions we used the
`VarStore` to generate unique identifiers for new variables created
during desugaring. We should have instead used the current module's
`Scope`, which handles identifiers within the module. Each scope has its
own incrementing variable count which is independent of the shared
variable store. The scope is used to generate new identifiers at other
points in canonicalization, such as when assigning a global identifier
to closures and `expect`s. It's possible that the identifier generated
for `dbg` could conflict with an identifier generated by the scope,
resulting in a confusing error.
2024-09-03 14:00:39 -04:00
Anton-4
02cf61f985
Merge pull request #7038 from mulias/expr-dbg
Support `dbg` in expressions
2024-09-02 13:30:32 +02:00
Anton-4
3c679f6338
Merge branch 'main' into lower-module-params 2024-08-30 16:29:46 +02:00
Elias Mulhall
56c5b790a7 Refactor dbg expression parsing to work more like function application
Instead of parsing dbg with an expression block, parse the dbg keyword
with no additional arguments. This way the parser treats dbg just like a
variable in function application. We desugar by pattern matching on
`Apply(Dbg, args, called_via)` nodes. This changes the output of syntax
tests since the initial AST is different, but does not change the output
of can or mono.

Add two new errors for dbg in expression position with either no args or
too many args. This is similar to the error behavior of `crash`.

Continue to parse dbg statements with an expression block, as before.
2024-08-29 15:36:48 -04:00
Elias Mulhall
2242e9b2c3 Remove error handling for dbg in expression position 2024-08-28 11:53:44 -04:00
Elias Mulhall
a16f757164 Pass var_store into desugar_expr so that desugaring may generate fresh vars 2024-08-28 11:53:44 -04:00
Agus Zubiaga
287a8fa2e7
Merge branch 'main' into lower-module-params 2024-08-28 08:50:40 -03:00
Sam Mohr
12df3a04de
Merge attempt 2024-08-19 23:34:05 -07:00
Agus Zubiaga
519ff56a85
Create can::module::ModuleParams for convenience 2024-08-17 13:10:37 -03:00
Sam Mohr
50f6e11423
Deprecate backpassing to prepare for eventual removal 2024-08-16 22:36:04 -07:00
Sam Mohr
7c15c16ae0 Fix failing test_reporting tests 2024-08-13 01:35:00 -07:00
Sam Mohr
7e72541a79 Merge branch 'main' into builtin-task 2024-08-12 23:12:38 -07:00
Agus Zubiaga
b451e69b20
Merge branch 'main' into typecheck-module-params 2024-08-12 22:27:16 -03:00
Joshua Warner
d25c048d48
Move Full from fmt to parse and reorganize confusingly-named Module ast type 2024-08-07 23:01:49 -07:00
Agus Zubiaga
762799052e
Merge branch 'main' into typecheck-module-params 2024-08-07 18:55:33 -03:00
Sam Mohr
8288af3156
Merge branch 'main' into builtin-task 2024-07-31 13:36:32 -07:00
Anton-4
d23426ac47
Merge pull request #6941 from roc-lang/improve-tip
improve opaque types tip
2024-07-31 13:48:51 +02:00
Anton-4
30a76a092b
improve opaque types tip 2024-07-30 16:06:23 +02:00
Luke Boswell
eca453d07f
Merge remote-tracking branch 'remote/main' into builtin-task 2024-07-29 16:05:51 +10:00
Joshua Warner
df915b936d
Feedback: add doc comments, verbiage changes, capitalize Roc, remove a resolved TODO 2024-07-28 14:45:32 -07:00
Richard Feldman
413de7f72e
s/roc/Roc in an error message
Signed-off-by: Richard Feldman <oss@rtfeldman.com>
2024-07-28 11:37:40 -04:00
Joshua Warner
4f32f43048
Implement block / indent based parsing
... and enforce that defs can only occur in blocks (or, inside parenthesized expressions)
2024-07-27 13:34:16 -07:00
Kiryl Dziamura
0086a531a2
add todo tests 2024-07-23 23:16:50 +02:00
Luke Boswell
b489c44b19
Merge remote-tracking branch 'remote/main' into builtin-task 2024-07-19 19:51:50 +10:00
Sam Mohr
74f05eca40
Fix broken test_reporting test 2024-07-07 19:02:31 -07:00
Sam Mohr
fe1b6d71fc
Update from PR comments 2024-07-07 18:33:20 -07:00
Sam Mohr
f415017c90
Implement new builder syntax alongside old one 2024-07-07 03:28:59 -07:00
Agus Zubiaga
26fe91b02f
Always use "MODULE PARAMS" term in errors
The theory is that this will be more searchable
2024-07-06 22:07:29 -03:00
Agus Zubiaga
0cbb352a89
Move unexpected params warning to solve 2024-07-06 21:36:26 -03:00
Sam Mohr
6f5f5f431e
Merge branch 'main' into builtin-task 2024-07-03 13:37:46 -07:00
Agus Zubiaga
13ba59a4cb
Fix hang on qualified import with builtin name 2024-07-03 12:40:53 -03:00
Sam Mohr
f61b303a59
Merge branch 'main' into builtin-task 2024-07-03 00:42:48 -07:00
Agus Zubiaga
922b1c44ef
Report missing params 2024-07-02 11:10:00 -03:00
Agus Zubiaga
bc6a84a215
Report unexpected params 2024-07-02 11:09:59 -03:00
Agus Zubiaga
5ec4b042bb
Constrain and solve import params
No reporting yet
2024-07-02 04:10:46 -03:00
Agus Zubiaga
dd0e28240a
Add module param identifiers to solve's scope 2024-07-02 04:10:45 -03:00
shua
d90da3af52
rm TotallyNotJson
TotallyNotJson.roc now lives on the farm in virtual-dom-wip as Json.roc.
Any reference in stdlib or builtins has been removed, as well as the
last places it was used (in python/ruby-interop examples).
2024-07-01 20:37:23 +02:00
shua
0faa1d5f20
test_gen: replace stdlib Json with inline implementation
Towards the goal of removing Json from stdlib, this change replaces
usage of TotallyNotJson in test_gen/gen_abilities with a simple usable
inline implementation of Encoder/DecoderFormatting.

Similarly, the use of TotallyNotJson in test_reporting is not necessary
at all and is replaced with a Decoder that wouldn't actually work, but
which does compile.
2024-07-01 20:30:05 +02:00
Sam Mohr
700c7ae9aa
Add Task as a built-in module/type 2024-06-25 00:03:56 -07:00