Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions crates/core/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::target::{
DiscriminatorVariantInfo, EnumMember, EnumMemberNamingStrategy, Expr, Field,
FilePartitioningStrategy, Item, Strategy, Target,
};
use crate::Error;
use ast::{Ast, SchemaAst};
use jtd::Schema;
use namespace::Namespace;
Expand Down Expand Up @@ -120,8 +121,11 @@ impl<'a, T: Target> CodeGenerator<'a, T> {
// Ref nodes are a special sort of "expr-like" node, where we
// already know what the name of the expression is; it's the name of
// the definition.
Ast::Ref { definition, .. } => self.definition_names[&definition].clone(),

Ast::Ref { definition, .. } => self
.definition_names
.get(&definition)
.ok_or_else(|| Error::UnknownReference(definition.clone()))?
.clone(),
// The remaining "expr-like" node types just build up strings and
// possibly alter the per-file state (usually in order to add
// "imports" to the file).
Expand Down
3 changes: 3 additions & 0 deletions crates/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ pub enum Error {

#[error("i/o error: {0}")]
Io(#[from] io::Error),

#[error("unknown reference: {0}")]
UnknownReference(String),
}