Fixed span calculation for backpassing (sort of)
This commit is contained in:
parent
eb4a43719c
commit
213ad48de7
|
@ -1806,7 +1806,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
mut continuation: Vec<UntypedExpr>,
|
mut continuation: Vec<UntypedExpr>,
|
||||||
) -> UntypedExpr {
|
) -> UntypedExpr {
|
||||||
let UntypedExpr::Assignment {
|
let UntypedExpr::Assignment {
|
||||||
location: _,
|
location,
|
||||||
value,
|
value,
|
||||||
kind,
|
kind,
|
||||||
patterns,
|
patterns,
|
||||||
|
@ -1818,7 +1818,15 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
let value_location = value.location();
|
let value_location = value.location();
|
||||||
|
|
||||||
let call_location = Span {
|
let call_location = Span {
|
||||||
start: value_location.end,
|
start: location.start,
|
||||||
|
end: continuation
|
||||||
|
.last()
|
||||||
|
.map(|expr| expr.location().end)
|
||||||
|
.unwrap_or_else(|| value_location.end),
|
||||||
|
};
|
||||||
|
|
||||||
|
let lambda_span = Span {
|
||||||
|
start: location.end, // Start immediately after the assignment
|
||||||
end: continuation
|
end: continuation
|
||||||
.last()
|
.last()
|
||||||
.map(|expr| expr.location().end)
|
.map(|expr| expr.location().end)
|
||||||
|
@ -1848,7 +1856,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
location: var_location,
|
location: var_location,
|
||||||
};
|
};
|
||||||
|
|
||||||
names.push((name, assignment_pattern_location, annotation));
|
names.push((name, var_location, annotation));
|
||||||
}
|
}
|
||||||
Pattern::Discard {
|
Pattern::Discard {
|
||||||
name,
|
name,
|
||||||
|
@ -1860,15 +1868,17 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
location: var_location,
|
location: var_location,
|
||||||
};
|
};
|
||||||
|
|
||||||
names.push((name, assignment_pattern_location, annotation));
|
names.push((name, var_location, annotation));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
let name = format!("{}_{}", ast::BACKPASS_VARIABLE, index);
|
let name = format!("{}_{}", ast::BACKPASS_VARIABLE, index);
|
||||||
|
|
||||||
|
let pattern_location = pattern.location();
|
||||||
|
|
||||||
let arg_name = ArgName::Named {
|
let arg_name = ArgName::Named {
|
||||||
label: name.clone(),
|
label: name.clone(),
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
location: pattern.location(),
|
location: pattern_location,
|
||||||
};
|
};
|
||||||
|
|
||||||
let pattern_is_var = pattern.is_var();
|
let pattern_is_var = pattern.is_var();
|
||||||
|
@ -1878,7 +1888,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
UntypedExpr::Assignment {
|
UntypedExpr::Assignment {
|
||||||
location: assignment_pattern_location,
|
location: assignment_pattern_location,
|
||||||
value: UntypedExpr::Var {
|
value: UntypedExpr::Var {
|
||||||
location: assignment_pattern_location,
|
location: pattern_location,
|
||||||
name: name.clone(),
|
name: name.clone(),
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
|
@ -1902,7 +1912,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
names.push((arg_name, assignment_pattern_location, annotation));
|
names.push((arg_name, pattern_location, annotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1949,9 +1959,9 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
location: call_location,
|
location: call_location,
|
||||||
fun: value,
|
fun: value,
|
||||||
arguments: vec![CallArg {
|
arguments: vec![CallArg {
|
||||||
location: call_location,
|
location: lambda_span,
|
||||||
label: None,
|
label: None,
|
||||||
value: UntypedExpr::lambda(names, continuation, call_location),
|
value: UntypedExpr::lambda(names, continuation, lambda_span),
|
||||||
}],
|
}],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1976,9 +1986,9 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
location: call_location,
|
location: call_location,
|
||||||
fun: value,
|
fun: value,
|
||||||
arguments: vec![CallArg {
|
arguments: vec![CallArg {
|
||||||
location: call_location,
|
location: lambda_span,
|
||||||
label: None,
|
label: None,
|
||||||
value: UntypedExpr::lambda(names, continuation, call_location),
|
value: UntypedExpr::lambda(names, continuation, lambda_span),
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue