Commit graph

18 commits

Author SHA1 Message Date
Sam Mohr
fce14d31b0
Move desugaring to new roc_can_solo crate 2025-01-19 07:16:43 -08:00
Sam Mohr
2150ee2219
Remove Task from Roc 2025-01-08 17:00:40 -08:00
JRI98
90f517712a
Remove unused code 2024-12-05 09:18:52 +00:00
Agus Zubiaga
01c94050c8
Detect fx mode based on hosted module 2024-11-07 18:54:15 -03: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
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
Agus Zubiaga
5112e064e5
Add module_path to can env instead of threading it through 2024-04-21 10:30:34 -03:00
Agus Zubiaga
1f347f6ca1
Fix package module resolution in inline imports
We were still passing `ModuleIds` from `load` to `can`, but now
that imports can appear in any scope, we don't know which package
an unqualified module name belongs to from the top level.

We now pass `PackageModuleIds` instead  and keep a Map of `ModuleName` to
`ModuleId` in `Scope`.

This also allow us to import multiple modules with the same name from different
packages as long as a unique alias is provided.
2024-04-20 12:16:37 -03:00
Agus Zubiaga
d5a38a26db
Merge branch 'main' into inline-imports 2024-04-20 12:01:11 -03:00
Luke Boswell
e74501981e
fmt and clippy fixes 2024-03-20 12:31:04 +11:00
Luke Boswell
3b2e9e36b8
rename operator.rs to desugar.rs 2024-03-17 15:57:27 +11:00
Agus Zubiaga
002493e32c
Load and can ingested file imports
Moves handling of ingested file imports from load to can, so that they
can be properly introduced in the scope they appear.

Example:

  import "input.txt" as input : Str

  image =
      import "image.png" as bytes : List U8
      # `bytes` is only available under `image`
      decodePng bytes

  ...
2024-01-20 08:43:40 -03:00
Brendan Hansknecht
3966d63e2f
add src and location to dbg 2023-12-02 21:18:31 -08:00
Folkert
ef39bad7c6
auto clippy fixes 2023-07-10 18:27:08 +02:00
Ayaz Hafiz
debe6332c5
Support OIOP for type aliases 2022-10-31 09:38:21 -05:00
Anton-4
eee85fa45d
moved all crates into seperate folder + related path fixes 2022-07-01 17:37:43 +02:00
Renamed from compiler/can/tests/helpers/mod.rs (Browse further)