Improve error
This commit is contained in:
parent
92f098b58b
commit
7ec640a3a1
@ -218,7 +218,9 @@ impl AbstractNode for ValueNode {
|
||||
r#type,
|
||||
),
|
||||
(None, Some(_)) => {
|
||||
return Err(ValidationError::ExpectedNonValueStatement(body.position))
|
||||
return Err(ValidationError::ExpectedNonValueStatement(
|
||||
body.node.last_statement().position(),
|
||||
))
|
||||
}
|
||||
(Some(constructor), None) => {
|
||||
return Err(ValidationError::ExpectedValueStatement(
|
||||
|
@ -345,10 +345,16 @@ impl InterpreterError {
|
||||
Label::new((self.source_id.clone(), position.0..position.1))
|
||||
.with_message("Expected a statement that yields a value."),
|
||||
),
|
||||
ValidationError::ExpectedNonValueStatement(position) => builder.add_label(
|
||||
Label::new((self.source_id.clone(), position.0..position.1))
|
||||
.with_message("Expected a statement that does not yield a value."),
|
||||
),
|
||||
ValidationError::ExpectedNonValueStatement(position) => {
|
||||
builder.add_label(
|
||||
Label::new((self.source_id.clone(), position.0..position.1))
|
||||
.with_message("Expected a statement that does not yield a value."),
|
||||
);
|
||||
builder.add_label(
|
||||
Label::new((self.source_id.clone(), position.0..position.1))
|
||||
.with_message("Try adding a semicolon here."),
|
||||
);
|
||||
}
|
||||
ValidationError::ExpectedFunction { actual, position } => builder.add_label(
|
||||
Label::new((self.source_id.clone(), position.0..position.1)).with_message(
|
||||
format!(
|
||||
|
Loading…
Reference in New Issue
Block a user