Skip to content

Commit

Permalink
fix: give "correct" error when trying to use AsTraitPath (#7360)
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Feb 13, 2025
1 parent c3deb6a commit 8f20392
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/elaborator/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<'context> Elaborator<'context> {
(HirExpression::Error, Type::Error)
}
ExpressionKind::AsTraitPath(_) => {
self.push_err(ResolverError::UnquoteUsedOutsideQuote { span: expr.span });
self.push_err(ResolverError::AsTraitPathNotYetImplemented { span: expr.span });
(HirExpression::Error, Type::Error)
}
ExpressionKind::TypePath(path) => return self.elaborate_type_path(path),
Expand Down
9 changes: 9 additions & 0 deletions compiler/noirc_frontend/src/hir/resolution/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ pub enum ResolverError {
ArrayLengthInterpreter { error: InterpreterError },
#[error("The unquote operator '$' can only be used within a quote expression")]
UnquoteUsedOutsideQuote { span: Span },
#[error("\"as trait path\" not yet implemented")]
AsTraitPathNotYetImplemented { span: Span },
#[error("Invalid syntax in macro call")]
InvalidSyntaxInMacroCall { span: Span },
#[error("Macros must be comptime functions")]
Expand Down Expand Up @@ -548,6 +550,13 @@ impl<'a> From<&'a ResolverError> for Diagnostic {
*span,
)
},
ResolverError::AsTraitPathNotYetImplemented { span } => {
Diagnostic::simple_error(
"\"as trait path\" not yet implemented".into(),
"".into(),
*span,
)
},
ResolverError::InvalidSyntaxInMacroCall { span } => {
Diagnostic::simple_error(
"Invalid syntax in macro call".into(),
Expand Down

0 comments on commit 8f20392

Please sign in to comment.