Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mutating FunctionDefinition functions #5685

Merged
merged 23 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/elaborator/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'context> Elaborator<'context> {

/// Equivalent to `elaborate_pattern`, this version just also
/// adds any new DefinitionIds that were created to the given Vec.
pub(super) fn elaborate_pattern_and_store_ids(
pub fn elaborate_pattern_and_store_ids(
&mut self,
pattern: Pattern,
expected_type: Type,
Expand Down
11 changes: 11 additions & 0 deletions compiler/noirc_frontend/src/hir/comptime/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@
FailedToResolveTraitDefinition {
location: Location,
},
FunctionAlreadyResolved {
location: Location,
},

Unimplemented {
item: String,
Expand Down Expand Up @@ -255,6 +258,7 @@
| InterpreterError::TraitDefinitionMustBeAPath { location }
| InterpreterError::FailedToResolveTraitDefinition { location }
| InterpreterError::FailedToResolveTraitBound { location, .. } => *location,
InterpreterError::FunctionAlreadyResolved { location, .. } => *location,

InterpreterError::FailedToParseMacro { error, file, .. } => {
Location::new(error.span(), *file)
Expand Down Expand Up @@ -441,7 +445,7 @@
let message = format!("Failed to parse macro's token stream into {rule}");
let tokens = vecmap(tokens.iter(), ToString::to_string).join(" ");

// 10 is an aribtrary number of tokens here chosen to fit roughly onto one line

Check warning on line 448 in compiler/noirc_frontend/src/hir/comptime/errors.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (aribtrary)
let token_stream = if tokens.len() > 10 {
format!("The resulting token stream was: {tokens}")
} else {
Expand Down Expand Up @@ -516,6 +520,13 @@
let msg = "Failed to resolve to a trait definition".to_string();
CustomDiagnostic::simple_error(msg, String::new(), location.span)
}
InterpreterError::FunctionAlreadyResolved { location } => {
let msg = "Function already resolved".to_string();
let secondary =
"The function was previously called at compile-time or is in another crate"
.to_string();
CustomDiagnostic::simple_error(msg, secondary, location.span)
}
}
}
}
Loading
Loading