Merge pull request #7533 from smores56/simple-can-solo

Move desugaring to new `roc_can_solo` crate
This commit is contained in:
Sam Mohr 2025-01-19 19:06:10 -08:00 committed by GitHub
commit 809fe23afd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 3282 additions and 2630 deletions

View file

@ -9,6 +9,7 @@ version.workspace = true
[dependencies]
roc_can.workspace = true
roc_can_solo.workspace = true
roc_collections.workspace = true
roc_load_internal.workspace = true
roc_module.workspace = true

View file

@ -3,11 +3,12 @@ extern crate bumpalo;
use self::bumpalo::Bump;
use roc_can::abilities::AbilitiesStore;
use roc_can::constraint::{Constraint, Constraints};
use roc_can::desugar;
use roc_can::env::Env;
use roc_can::expected::Expected;
use roc_can::expr::{canonicalize_expr, Expr, Output, PendingDerives};
use roc_can::scope::Scope;
use roc_can_solo::env::SoloEnv;
use roc_can_solo::scope::SoloScope;
use roc_collections::all::{ImMap, MutMap, SendSet};
use roc_constrain::expr::constrain_expr;
use roc_derive::SharedDerivedModule;
@ -162,24 +163,6 @@ pub fn can_expr_with<'a>(
// ensure the Test module is accessible in our tests
module_ids.get_or_insert(&PQModuleName::Unqualified("Test".into()));
let mut scope = Scope::new(
home,
"TestPath".into(),
IdentIds::default(),
Default::default(),
);
let dep_idents = IdentIds::exposed_builtins(0);
let mut env = Env::new(
arena,
expr_str,
home,
Path::new("Test.roc"),
&dep_idents,
&module_ids,
None,
);
// Desugar operators (convert them to Apply calls, taking into account
// operator precedence and associativity rules), before doing other canonicalization.
//
@ -187,7 +170,9 @@ pub fn can_expr_with<'a>(
// visited a BinOp node we'd recursively try to apply this to each of its nested
// operators, and then again on *their* nested operators, ultimately applying the
// rules multiple times unnecessarily.
let loc_expr = desugar::desugar_expr(&mut env, &mut scope, &loc_expr);
let mut solo_env = SoloEnv::new(arena, expr_str, Path::new("Test.roc"));
let mut solo_scope = SoloScope::new();
let loc_expr = roc_can_solo::desugar::desugar_expr(&mut solo_env, &mut solo_scope, &loc_expr);
let mut scope = Scope::new(
home,