Skip to content

Commit

Permalink
Fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
GearsDatapacks authored and lpil committed Jan 25, 2025
1 parent d0a6a84 commit 20d440b
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions compiler-core/src/type_/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,13 +1325,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {

let value_typ = value.type_();

let kind = match self.infer_assignment_kind(kind) {
Ok(kind) => kind,
Err(error) => {
self.problems.error(error);
AssignmentKind::Generated
}
};
let kind = self.infer_assignment_kind(kind.clone());

// Ensure the pattern matches the type of the value
let pattern_location = pattern.location();
Expand Down Expand Up @@ -1401,26 +1395,31 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
fn infer_assignment_kind(
&mut self,
kind: AssignmentKind<UntypedExpr>,
) -> Result<AssignmentKind<TypedExpr>, Error> {
) -> AssignmentKind<TypedExpr> {
match kind {
AssignmentKind::Let => Ok(AssignmentKind::Let),
AssignmentKind::Generated => Ok(AssignmentKind::Generated),
AssignmentKind::Let => AssignmentKind::Let,
AssignmentKind::Generated => AssignmentKind::Generated,
AssignmentKind::Assert { location, message } => {
let message = match message {
Some(message) => {
self.track_feature_usage(
FeatureKind::LetAssertWithMessage,
message.location(),
);
let message = self.infer(*message)?;
let message = self.infer(*message).unwrap_or_else(|error| {
self.problems.error(error);
self.error_expr(location)
});

unify(string(), message.type_())
.map_err(|e| convert_unify_error(e, message.location()))?;
let _ = unify(string(), message.type_()).map_err(|e| {
self.problems
.error(convert_unify_error(e, message.location()))
});
Some(Box::new(message))
}
None => None,
};
Ok(AssignmentKind::Assert { location, message })
AssignmentKind::Assert { location, message }
}
}
}
Expand Down

0 comments on commit 20d440b

Please sign in to comment.