-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Error when a type variable is unbound during monomorphization in…
…stead of defaulting to Field (#4674) # Description ## Problem\* Resolves <!-- Link to GitHub Issue --> ## Summary\* Adds an error when encountering an unbound `TypeVariableKind::Normal` instead of defaulting it to a Field. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
- Loading branch information
Showing
17 changed files
with
356 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use thiserror::Error; | ||
|
||
use noirc_errors::{CustomDiagnostic, FileDiagnostic, Location}; | ||
|
||
#[derive(Debug, Error)] | ||
pub enum MonomorphizationError { | ||
#[error("Length of generic array could not be determined.")] | ||
UnknownArrayLength { location: Location }, | ||
|
||
#[error("Type annotations needed")] | ||
TypeAnnotationsNeeded { location: Location }, | ||
} | ||
|
||
impl MonomorphizationError { | ||
fn location(&self) -> Location { | ||
match self { | ||
MonomorphizationError::UnknownArrayLength { location } | ||
| MonomorphizationError::TypeAnnotationsNeeded { location } => *location, | ||
} | ||
} | ||
} | ||
|
||
impl From<MonomorphizationError> for FileDiagnostic { | ||
fn from(error: MonomorphizationError) -> FileDiagnostic { | ||
let location = error.location(); | ||
let call_stack = vec![location]; | ||
let diagnostic = error.into_diagnostic(); | ||
diagnostic.in_file(location.file).with_call_stack(call_stack) | ||
} | ||
} | ||
|
||
impl MonomorphizationError { | ||
fn into_diagnostic(self) -> CustomDiagnostic { | ||
let message = self.to_string(); | ||
let location = self.location(); | ||
|
||
CustomDiagnostic::simple_error(message, String::new(), location.span) | ||
} | ||
} |
Oops, something went wrong.