Skip to content

Commit

Permalink
add source metadata to VariableAlreadyDeclared error
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobhellermann committed Jun 1, 2021
1 parent c96c4be commit b5814b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/front/glsl/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ pub enum ErrorKind {
#[error("Unknown layout qualifier: {1}")]
UnknownLayoutQualifier(SourceMetadata, String),
#[cfg(feature = "glsl-validate")]
#[error("Variable already declared: {0}")]
VariableAlreadyDeclared(String),
#[error("Variable already declared: {1}")]
VariableAlreadyDeclared(SourceMetadata, String),
#[error("{1}")]
SemanticError(SourceMetadata, Cow<'static, str>),
}
Expand All @@ -48,7 +48,8 @@ impl ErrorKind {
| ErrorKind::InvalidVersion(metadata, _)
| ErrorKind::UnknownLayoutQualifier(metadata, _)
| ErrorKind::SemanticError(metadata, _)
| ErrorKind::UnknownField(metadata, _) => Some(metadata),
| ErrorKind::UnknownField(metadata, _)
| ErrorKind::VariableAlreadyDeclared(metadata, _) => Some(metadata),
ErrorKind::InvalidToken(ref token, _) => Some(token.meta),
_ => None,
}
Expand Down
2 changes: 1 addition & 1 deletion src/front/glsl/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl Program<'_> {
) -> Result<Handle<Expression>, ErrorKind> {
#[cfg(feature = "glsl-validate")]
if ctx.lookup_local_var_current_scope(&name).is_some() {
return Err(ErrorKind::VariableAlreadyDeclared(name));
return Err(ErrorKind::VariableAlreadyDeclared(meta, name));
}

let mut mutable = true;
Expand Down

0 comments on commit b5814b6

Please sign in to comment.