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