Commit graph

50 commits

Author SHA1 Message Date
Anthony Bullard
c70ceb4f98
Issue 7089: ?? operator 2024-12-26 10:53:47 -06:00
Joshua Warner
b4fdb0a4c2
Make dbg parse strictly as an Apply
This is important in order to fix some formatting bugs found in fuzzing
2024-11-24 14:15:29 -08:00
Agus Zubiaga
01c94050c8
Detect fx mode based on hosted module 2024-11-07 18:54:15 -03:00
Luke Boswell
afb247d4c3
ignore final suffix for annotated top-level defs 2024-09-29 10:57:18 +10:00
Luke Boswell
cce33c03d6
desugar ValueDef::Expect suffixed nodes 2024-09-23 17:57:25 +10:00
Elias Mulhall
19931ecd43
Support passing values into dbg with the pipe operator
In order to desugar `dbg` in a pipeline we need to allow a bare `dbg`
node in desugaring and only report it as an error if the bare node
survives to the next step of canonicalization. This means we move the
error code out of `desugar_expr` and into `canonicalize_expr`. This is
much simpler to do now that these functions use the same `env` struct,
since previously we would have had to pass down extra args to
`canonicalize_expr`. Sharing the `env` struct means that we also don't
have to worry about calculating `line_info` more than once.
2024-09-05 20:13:54 -04: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
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
Elias Mulhall
7a07f13f31 Test dbg expr desugaring 2024-08-28 12:16:22 -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
Sam Mohr
50f6e11423
Deprecate backpassing to prepare for eventual removal 2024-08-16 22:36:04 -07:00
Kiryl Dziamura
7aa31a1639
code cleanup 2024-07-23 23:16:50 +02:00
Kiryl Dziamura
863fb3b29f
remove obsolete test 2024-07-23 23:16:50 +02:00
Kiryl Dziamura
56eae5df95
propagate type annotations to desugared ast 2024-07-23 23:16:47 +02:00
Kiryl Dziamura
1c01a8f0d3
remove measleading fmt code from snapshots 2024-07-14 09:52:01 +02:00
Kiryl Dziamura
8949fc710b
use snapshots for suffixed tests 2024-07-13 20:46:22 +02:00
Kiryl Dziamura
3f22c55dda
fix suffixed tests 2024-07-08 11:39:04 +02:00
Kiryl Dziamura
819cfd6035
fix test snapshots 2024-07-01 19:48:00 +02:00
Kiryl Dziamura
6329389972
add tests 2024-07-01 19:47:49 +02:00
Kiryl Dziamura
9c133f72d8
test bang in dbg arg 2024-06-28 13:31:47 +02:00
Kiryl Dziamura
bff73ff6b2
check if final expr in deps is suffixed 2024-06-25 19:14:18 +02:00
Kiryl Dziamura
3e5cfb546d
check if when branch is suffixed 2024-06-03 23:45:54 +02:00
Kiryl Dziamura
8883ab9a91
Desugar expect continuation 2024-06-03 16:58:31 +02:00
Kiryl Dziamura
e86c6235c1
add multiple args test 2024-05-28 11:34:01 +02:00
Kiryl Dziamura
ce6e21ff7a
ignore def pattern for function args 2024-05-27 18:21:00 +02:00
Luke Boswell
9a7b62ac22
handle dbg when unwrapping suffixed ! 2024-05-04 21:37:47 +02:00
Luke Boswell
20f277c132
update later tests 2024-04-28 08:47:08 +10:00
Luke Boswell
db4607125b
remove suffixed from Pattern 2024-04-28 08:47:08 +10:00
Luke Boswell
2fe03e6c91
remove suffixed from Expr::Var 2024-04-28 08:47:08 +10:00
Luke Boswell
1640ee1321
update logic for Expr::TaskAwaitBang 2024-04-28 08:47:08 +10:00
Luke Boswell
84cd4233be
clippy fix 2024-04-22 18:55:34 +10:00
Luke Boswell
32c4083364
add new tests for trailing ! 2024-04-22 18:38:26 +10:00
Richard Feldman
6059f7afcb
Merge pull request #6651 from roc-lang/fix-nesting-suffix
Fix recursion for suffixed `!` in top-level def
2024-04-19 14:53:34 -04:00
Luke Boswell
5e738a4ab5
fix recursion in top-level def 2024-04-19 10:34:33 +10:00
Luke Boswell
ae908f89a9
suffixed when branches 2024-04-18 12:47:11 +10:00
Luke Boswell
a889810dfd
unwrap suffixed when condition 2024-04-18 09:44:57 +10:00
Luke Boswell
0198a683c7
fix unwrapping of trailing expr 2024-04-17 09:54:29 +10:00
Luke Boswell
7a84dcd39c
don't unwrap intermediate answer if not required 2024-04-16 16:25:20 +10:00
Luke Boswell
7c94e4db04
cargo fmt 2024-04-15 14:38:20 +10:00
Luke Boswell
ee42dfc317
add support for if-then-else 2024-04-15 14:20:49 +10:00
Luke Boswell
2a222f3a51
optimise by not unwrapping sometimes 2024-04-15 10:02:03 +10:00
Luke Boswell
7886d30b8e
parse/unwrap nested defs 2024-04-15 09:25:00 +10:00
Luke Boswell
93ef5e42dc
fix tests, make clippy happy 2024-04-14 13:45:07 +10:00
Luke Boswell
f9fb59f0c2
cleanup and refactor suffixed tests 2024-04-14 13:45:07 +10:00
Luke Boswell
0143035dc0
cleanup, improve docs 2024-04-14 13:45:06 +10:00
Luke Boswell
c32fa5b600
support optional suffied last def 2024-04-14 13:45:06 +10:00
Luke Boswell
bd264eb5c3
add new tests 2024-04-14 13:45:06 +10:00
Luke Boswell
5bb44fcce5
most tests passing 2024-04-14 13:45:05 +10:00
Luke Boswell
f1d568b848
WIP try simplification 2024-04-14 13:45:05 +10:00
Luke Boswell
8b9e08bd76
WIP try simplification 2024-04-14 13:45:05 +10:00