Skip to content

Commit

Permalink
Minor changes in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp authored and David Peter committed May 15, 2024
1 parent 59f52a1 commit e824cfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion numbat/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl ErrorDiagnostic for TypeCheckError {
.diagnostic_label(LabelStyle::Secondary)
.with_message("Already defined here"),
]),
TypeCheckError::MissingFieldsFromStructConstruction(
TypeCheckError::MissingFieldsInStructInstantiation(
construction_span,
defn_span,
missing,
Expand Down
22 changes: 11 additions & 11 deletions numbat/src/typechecker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,23 +305,23 @@ pub enum TypeCheckError {
#[error("Unknown struct '{1}")]
UnknownStruct(Span, String),

#[error("Unknown field {2} of struct {3}")]
#[error("Unknown field '{2}' of struct '{3}'")]
UnknownFieldOfStruct(Span, Span, String, String),

#[error("Duplicate field {2} in struct definition")]
#[error("Duplicate field '{2}' in struct definition")]
DuplicateFieldInStructDefinition(Span, Span, String),

#[error("Duplicate field {2} in struct construction")]
#[error("Duplicate field '{2}' in struct instantiation")]
DuplicateFieldInStructConstruction(Span, Span, String),

#[error("Accessing field {2} of non struct type {3}")]
#[error("Accessing field '{2}' of non struct type '{3}'")]
AccessingFieldOfNonStruct(Span, Span, String, Type),

#[error("Accessing unknown field {2} of struct {3}")]
#[error("Accessing unknown field '{2}' of struct '{3}'")]
AccessingUnknownFieldOfStruct(Span, Span, String, Type),

#[error("Missing fields from struct construction")]
MissingFieldsFromStructConstruction(Span, Span, Vec<(String, Type)>),
#[error("Missing fields in struct instantiation")]
MissingFieldsInStructInstantiation(Span, Span, Vec<(String, Type)>),

#[error(transparent)]
NameResolutionError(#[from] NameResolutionError),
Expand Down Expand Up @@ -445,10 +445,10 @@ fn evaluate_const_expr(expr: &typed_ast::Expression) -> Result<Exponent> {
))
}
e @ typed_ast::Expression::MakeStruct(_, _, _) => Err(
TypeCheckError::UnsupportedConstEvalExpression(e.full_span(), "make struct"),
TypeCheckError::UnsupportedConstEvalExpression(e.full_span(), "instantiate struct"),
),
e @ typed_ast::Expression::AccessStruct(_, _, _, _, _, _) => Err(
TypeCheckError::UnsupportedConstEvalExpression(e.full_span(), "access struct"),
TypeCheckError::UnsupportedConstEvalExpression(e.full_span(), "access field of struct"),
),
}
}
Expand Down Expand Up @@ -1213,7 +1213,7 @@ impl TypeChecker {
};

if !missing_fields.is_empty() {
return Err(TypeCheckError::MissingFieldsFromStructConstruction(
return Err(TypeCheckError::MissingFieldsInStructInstantiation(
*full_span,
struct_info.definition_span,
missing_fields,
Expand Down Expand Up @@ -2594,7 +2594,7 @@ mod tests {

assert!(matches!(
get_typecheck_error("SomeStruct {}"),
TypeCheckError::MissingFieldsFromStructConstruction(..)
TypeCheckError::MissingFieldsInStructInstantiation(..)
));
}

Expand Down

0 comments on commit e824cfb

Please sign in to comment.