mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Merge remote-tracking branch 'origin/trunk' into flat-declarations
This commit is contained in:
commit
b119986777
65 changed files with 3072 additions and 1287 deletions
|
@ -20,7 +20,7 @@ use roc_parse::ast::{self, EscapedChar, StrLiteral};
|
|||
use roc_parse::pattern::PatternType::*;
|
||||
use roc_problem::can::{PrecedenceProblem, Problem, RuntimeError};
|
||||
use roc_region::all::{Loc, Region};
|
||||
use roc_types::subs::{ExhaustiveMark, RedundantMark, VarStore, Variable};
|
||||
use roc_types::subs::{ExhaustiveMark, IllegalCycleMark, RedundantMark, VarStore, Variable};
|
||||
use roc_types::types::{Alias, Category, LambdaSet, OptAbleVar, Type};
|
||||
use std::fmt::{Debug, Display};
|
||||
use std::{char, u32};
|
||||
|
@ -88,8 +88,9 @@ pub enum Expr {
|
|||
AbilityMember(
|
||||
/// Actual member name
|
||||
Symbol,
|
||||
/// Specialization to use
|
||||
/// Specialization to use, and its variable
|
||||
SpecializationId,
|
||||
Variable,
|
||||
),
|
||||
|
||||
// Branching
|
||||
|
@ -115,7 +116,7 @@ pub enum Expr {
|
|||
},
|
||||
|
||||
// Let
|
||||
LetRec(Vec<Def>, Box<Loc<Expr>>),
|
||||
LetRec(Vec<Def>, Box<Loc<Expr>>, IllegalCycleMark),
|
||||
LetNonRec(Box<Def>, Box<Loc<Expr>>),
|
||||
|
||||
/// This is *only* for calling functions, not for tag application.
|
||||
|
@ -221,10 +222,10 @@ impl Expr {
|
|||
Self::SingleQuote(..) => Category::Character,
|
||||
Self::List { .. } => Category::List,
|
||||
&Self::Var(sym) => Category::Lookup(sym),
|
||||
&Self::AbilityMember(sym, _) => Category::Lookup(sym),
|
||||
&Self::AbilityMember(sym, _, _) => Category::Lookup(sym),
|
||||
Self::When { .. } => Category::When,
|
||||
Self::If { .. } => Category::If,
|
||||
Self::LetRec(_, expr) => expr.value.category(),
|
||||
Self::LetRec(_, expr, _) => expr.value.category(),
|
||||
Self::LetNonRec(_, expr) => expr.value.category(),
|
||||
&Self::Call(_, _, called_via) => Category::CallResult(None, called_via),
|
||||
&Self::RunLowLevel { op, .. } => Category::LowLevelOpResult(op),
|
||||
|
@ -699,7 +700,7 @@ pub fn canonicalize_expr<'a>(
|
|||
}
|
||||
}
|
||||
ast::Expr::Var { module_name, ident } => {
|
||||
canonicalize_var_lookup(env, scope, module_name, ident, region)
|
||||
canonicalize_var_lookup(env, var_store, scope, module_name, ident, region)
|
||||
}
|
||||
ast::Expr::Underscore(name) => {
|
||||
// we parse underscores, but they are not valid expression syntax
|
||||
|
@ -1313,6 +1314,7 @@ fn canonicalize_field<'a>(
|
|||
|
||||
fn canonicalize_var_lookup(
|
||||
env: &mut Env<'_>,
|
||||
var_store: &mut VarStore,
|
||||
scope: &mut Scope,
|
||||
module_name: &str,
|
||||
ident: &str,
|
||||
|
@ -1329,7 +1331,11 @@ fn canonicalize_var_lookup(
|
|||
output.references.insert_value_lookup(symbol);
|
||||
|
||||
if scope.abilities_store.is_ability_member_name(symbol) {
|
||||
AbilityMember(symbol, scope.abilities_store.fresh_specialization_id())
|
||||
AbilityMember(
|
||||
symbol,
|
||||
scope.abilities_store.fresh_specialization_id(),
|
||||
var_store.fresh(),
|
||||
)
|
||||
} else {
|
||||
Var(symbol)
|
||||
}
|
||||
|
@ -1348,7 +1354,11 @@ fn canonicalize_var_lookup(
|
|||
output.references.insert_value_lookup(symbol);
|
||||
|
||||
if scope.abilities_store.is_ability_member_name(symbol) {
|
||||
AbilityMember(symbol, scope.abilities_store.fresh_specialization_id())
|
||||
AbilityMember(
|
||||
symbol,
|
||||
scope.abilities_store.fresh_specialization_id(),
|
||||
var_store.fresh(),
|
||||
)
|
||||
} else {
|
||||
Var(symbol)
|
||||
}
|
||||
|
@ -1507,7 +1517,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
|
|||
Expect(Box::new(loc_condition), Box::new(loc_expr))
|
||||
}
|
||||
|
||||
LetRec(defs, loc_expr) => {
|
||||
LetRec(defs, loc_expr, mark) => {
|
||||
let mut new_defs = Vec::with_capacity(defs.len());
|
||||
|
||||
for def in defs {
|
||||
|
@ -1528,7 +1538,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
|
|||
value: inline_calls(var_store, scope, loc_expr.value),
|
||||
};
|
||||
|
||||
LetRec(new_defs, Box::new(loc_expr))
|
||||
LetRec(new_defs, Box::new(loc_expr), mark)
|
||||
}
|
||||
|
||||
LetNonRec(def, loc_expr) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue