Skip to content

Commit

Permalink
feat: add diagnostic for unrecognized standard library headers
Browse files Browse the repository at this point in the history
  • Loading branch information
aspizu committed Jan 14, 2025
1 parent 0b8434a commit 26d5aed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/diagnostic/diagnostic_kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub enum DiagnosticKind {
UnrecognizedStructField(SmolStr),
UnrecognizedEnumVariant(SmolStr),
UnrecognizedKey(SmolStr),
UnrecognizedStandardLibraryHeader,
NoCostumes,
BlockArgsCountMismatch {
block: Block,
Expand Down Expand Up @@ -115,6 +116,9 @@ impl DiagnosticKind {
DiagnosticKind::UnrecognizedStructField(_) => "unrecognized struct field".to_string(),
DiagnosticKind::UnrecognizedEnumVariant(_) => "unrecognized enum variant".to_string(),
DiagnosticKind::UnrecognizedKey(_) => "unrecognized key".to_string(),
DiagnosticKind::UnrecognizedStandardLibraryHeader => {
"unrecognized standard library header".to_string()
}
DiagnosticKind::NoCostumes => "no costumes".to_string(),
DiagnosticKind::BlockArgsCountMismatch { block, given } => {
format!(
Expand Down Expand Up @@ -200,6 +204,7 @@ impl From<&DiagnosticKind> for Level {
| DiagnosticKind::UnrecognizedStructField(_)
| DiagnosticKind::UnrecognizedEnumVariant(_)
| DiagnosticKind::UnrecognizedKey(_)
| DiagnosticKind::UnrecognizedStandardLibraryHeader
| DiagnosticKind::NoCostumes
| DiagnosticKind::BlockArgsCountMismatch { .. }
| DiagnosticKind::ReprArgsCountMismatch { .. }
Expand Down
7 changes: 6 additions & 1 deletion src/translation_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ impl TranslationUnit {
"emoji" => include_bytes!("../std/emoji.gs").as_slice(),
"math" => include_bytes!("../std/math.gs").as_slice(),
"string" => include_bytes!("../std/string.gs").as_slice(),
_ => todo!("{path}"),
_ => {
return Err(Diagnostic {
kind: DiagnosticKind::UnrecognizedStandardLibraryHeader,
span: path_span,
});
}
};
(file, None)
} else {
Expand Down

0 comments on commit 26d5aed

Please sign in to comment.