Skip to content

Commit ced074e

Browse files
committed
wip
1 parent 8ef460f commit ced074e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

crates/compiler/can/src/expr.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ pub enum Expr {
151151
Box<(Variable, Loc<Expr>, Variable, Variable)>,
152152
Vec<(Variable, Loc<Expr>)>,
153153
CalledVia,
154+
bool,
154155
),
155156
RunLowLevel {
156157
op: LowLevel,
@@ -315,7 +316,7 @@ impl Expr {
315316
Self::If { .. } => Category::If,
316317
Self::LetRec(_, expr, _) => expr.value.category(),
317318
Self::LetNonRec(_, expr) => expr.value.category(),
318-
&Self::Call(_, _, called_via) => Category::CallResult(None, called_via),
319+
&Self::Call(_, _, called_via, _) => Category::CallResult(None, called_via),
319320
&Self::RunLowLevel { op, .. } => Category::LowLevelOpResult(op),
320321
Self::ForeignCall { .. } => Category::ForeignCall,
321322
Self::Closure(..) => Category::Lambda,
@@ -970,6 +971,7 @@ pub fn canonicalize_expr<'a>(
970971
)),
971972
args,
972973
*application_style,
974+
true,
973975
)
974976
}
975977
RuntimeError(_) => {
@@ -1009,6 +1011,7 @@ pub fn canonicalize_expr<'a>(
10091011
)),
10101012
args,
10111013
*application_style,
1014+
false,
10121015
)
10131016
}
10141017
};
@@ -2292,7 +2295,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
22922295
);
22932296
}
22942297

2295-
Call(boxed_tuple, args, called_via) => {
2298+
Call(boxed_tuple, args, called_via, tail_call) => {
22962299
let (fn_var, loc_expr, closure_var, expr_var) = *boxed_tuple;
22972300

22982301
match loc_expr.value {
@@ -2367,6 +2370,7 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
23672370
Box::new((fn_var, loc_expr, closure_var, expr_var)),
23682371
args,
23692372
called_via,
2373+
tail_call,
23702374
)
23712375
}
23722376
}
@@ -2663,6 +2667,7 @@ fn desugar_str_segments(var_store: &mut VarStore, segments: Vec<StrSegment>) ->
26632667
(var_store.fresh(), loc_expr),
26642668
],
26652669
CalledVia::StringInterpolation,
2670+
false,
26662671
);
26672672

26682673
loc_expr = Loc::at(Region::zero(), expr);
@@ -3177,7 +3182,7 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
31773182
stack.push(&def.loc_expr.value);
31783183
stack.push(&expr.value);
31793184
}
3180-
Expr::Call(boxed_expr, args, _called_via) => {
3185+
Expr::Call(boxed_expr, args, _called_via, tail_call) => {
31813186
stack.reserve(1 + args.len());
31823187

31833188
match &boxed_expr.1.value {

crates/compiler/can/src/traverse.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
289289
visitor.visit_def(def);
290290
visitor.visit_expr(&body.value, body.region, var);
291291
}
292-
Expr::Call(f, args, _called_via) => {
292+
Expr::Call(f, args, _called_via, tail_call) => {
293293
let (fn_var, loc_fn, _closure_var, _ret_var) = &**f;
294+
294295
walk_call(visitor, *fn_var, loc_fn, args);
295296
}
296297
Expr::Crash { msg, .. } => {

0 commit comments

Comments
 (0)