Continue error overhaul
This commit is contained in:
parent
88ca9c5ea4
commit
9a465cb42d
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, AssignmentOperator, Error, Format, Identifier, Map, SourcePosition, Statement,
|
AbstractTree, AssignmentOperator, Format, Identifier, Map, SourcePosition, Statement,
|
||||||
SyntaxNode, Type, TypeSpecification, Value,
|
SyntaxNode, Type, TypeSpecification, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ impl AbstractTree for Assignment {
|
|||||||
source: &str,
|
source: &str,
|
||||||
context: &Map,
|
context: &Map,
|
||||||
) -> Result<Self, SyntaxError> {
|
) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "assignment", syntax_node)?;
|
SyntaxError::expect_syntax_node(source, "assignment", syntax_node)?;
|
||||||
|
|
||||||
let child_count = syntax_node.child_count();
|
let child_count = syntax_node.child_count();
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, Map, SyntaxNode, Type, Value,
|
AbstractTree, Format, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Operators that be used in an assignment statement.
|
/// Operators that be used in an assignment statement.
|
||||||
@ -19,7 +19,7 @@ impl AbstractTree for AssignmentOperator {
|
|||||||
source: &str,
|
source: &str,
|
||||||
_context: &crate::Map,
|
_context: &crate::Map,
|
||||||
) -> Result<Self, SyntaxError> {
|
) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "assignment_operator", node)?;
|
SyntaxError::expect_syntax_node(source, "assignment_operator", node)?;
|
||||||
|
|
||||||
let operator_node = node.child(0).unwrap();
|
let operator_node = node.child(0).unwrap();
|
||||||
let operator = match operator_node.kind() {
|
let operator = match operator_node.kind() {
|
||||||
|
@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{rw_lock_error::RwLockError, RuntimeError, SyntaxError, ValidationError},
|
error::{rw_lock_error::RwLockError, RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, Map, Statement, SyntaxNode, Type, Value,
|
AbstractTree, Format, Map, Statement, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of a block.
|
/// Abstract representation of a block.
|
||||||
@ -24,7 +24,7 @@ pub struct Block {
|
|||||||
|
|
||||||
impl AbstractTree for Block {
|
impl AbstractTree for Block {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "block", node)?;
|
SyntaxError::expect_syntax_node(source, "block", node)?;
|
||||||
|
|
||||||
let first_child = node.child(0).unwrap();
|
let first_child = node.child(0).unwrap();
|
||||||
let is_async = first_child.kind() == "async";
|
let is_async = first_child.kind() == "async";
|
||||||
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, Map, Type, Value,
|
AbstractTree, Format, Map, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// An external program invokation.
|
/// An external program invokation.
|
||||||
@ -20,7 +20,7 @@ impl AbstractTree for Command {
|
|||||||
source: &str,
|
source: &str,
|
||||||
_context: &crate::Map,
|
_context: &crate::Map,
|
||||||
) -> Result<Self, SyntaxError> {
|
) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "command", node)?;
|
SyntaxError::expect_syntax_node(source, "command", node)?;
|
||||||
|
|
||||||
let command_text_node = node.child(1).unwrap();
|
let command_text_node = node.child(1).unwrap();
|
||||||
let command_text = source[command_text_node.byte_range()].to_string();
|
let command_text = source[command_text_node.byte_range()].to_string();
|
||||||
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
value_node::ValueNode,
|
value_node::ValueNode,
|
||||||
AbstractTree, Command, Error, Format, FunctionCall, Identifier, Index, Logic, Map, Math, New,
|
AbstractTree, Command, Format, FunctionCall, Identifier, Index, Logic, Map, Math, New,
|
||||||
SyntaxNode, Type, Value, Yield,
|
SyntaxNode, Type, Value, Yield,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ pub enum Expression {
|
|||||||
|
|
||||||
impl AbstractTree for Expression {
|
impl AbstractTree for Expression {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, _context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, _context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "expression", node)?;
|
SyntaxError::expect_syntax_node(source, "expression", node)?;
|
||||||
|
|
||||||
let child = if node.child(0).unwrap().is_named() {
|
let child = if node.child(0).unwrap().is_named() {
|
||||||
node.child(0).unwrap()
|
node.child(0).unwrap()
|
||||||
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Block, Error, Expression, Format, Identifier, Map, SyntaxNode, Type, Value,
|
AbstractTree, Block, Expression, Format, Identifier, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of a for loop statement.
|
/// Abstract representation of a for loop statement.
|
||||||
@ -17,7 +17,7 @@ pub struct For {
|
|||||||
|
|
||||||
impl AbstractTree for For {
|
impl AbstractTree for For {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "for", node)?;
|
SyntaxError::expect_syntax_node(source, "for", node)?;
|
||||||
|
|
||||||
let for_node = node.child(0).unwrap();
|
let for_node = node.child(0).unwrap();
|
||||||
let is_async = match for_node.kind() {
|
let is_async = match for_node.kind() {
|
||||||
|
@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Expression, Format, FunctionExpression, Map, SourcePosition, SyntaxNode,
|
AbstractTree, Expression, Format, FunctionExpression, Map, SourcePosition, SyntaxNode, Type,
|
||||||
Type, Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A function being invoked and the arguments it is being passed.
|
/// A function being invoked and the arguments it is being passed.
|
||||||
@ -31,7 +31,7 @@ impl FunctionCall {
|
|||||||
|
|
||||||
impl AbstractTree for FunctionCall {
|
impl AbstractTree for FunctionCall {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "function_call", node)?;
|
SyntaxError::expect_syntax_node(source, "function_call", node)?;
|
||||||
|
|
||||||
let function_node = node.child(0).unwrap();
|
let function_node = node.child(0).unwrap();
|
||||||
let function_expression = FunctionExpression::from_syntax(function_node, source, context)?;
|
let function_expression = FunctionExpression::from_syntax(function_node, source, context)?;
|
||||||
|
@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, FunctionCall, Identifier, Index, Map, SyntaxNode, Type, Value,
|
AbstractTree, Format, FunctionCall, Identifier, Index, Map, SyntaxNode, Type, Value, ValueNode,
|
||||||
ValueNode, Yield,
|
Yield,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
@ -17,7 +17,7 @@ pub enum FunctionExpression {
|
|||||||
|
|
||||||
impl AbstractTree for FunctionExpression {
|
impl AbstractTree for FunctionExpression {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "function_expression", node)?;
|
SyntaxError::expect_syntax_node(source, "function_expression", node)?;
|
||||||
|
|
||||||
let first_child = node.child(0).unwrap();
|
let first_child = node.child(0).unwrap();
|
||||||
let child = if first_child.is_named() {
|
let child = if first_child.is_named() {
|
||||||
|
@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Block, Error, Format, Function, Identifier, Map, SourcePosition, SyntaxNode,
|
AbstractTree, Block, Format, Function, Identifier, Map, SourcePosition, SyntaxNode, Type,
|
||||||
Type, TypeSpecification, Value,
|
TypeSpecification, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
@ -90,7 +90,7 @@ impl AbstractTree for FunctionNode {
|
|||||||
source: &str,
|
source: &str,
|
||||||
outer_context: &Map,
|
outer_context: &Map,
|
||||||
) -> Result<Self, SyntaxError> {
|
) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "function", node)?;
|
SyntaxError::expect_syntax_node(source, "function", node)?;
|
||||||
|
|
||||||
let child_count = node.child_count();
|
let child_count = node.child_count();
|
||||||
let mut parameters = Vec::new();
|
let mut parameters = Vec::new();
|
||||||
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, Map, SyntaxNode, Type, Value,
|
AbstractTree, Format, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A string by which a variable is known to a context.
|
/// A string by which a variable is known to a context.
|
||||||
@ -30,7 +30,7 @@ impl Identifier {
|
|||||||
|
|
||||||
impl AbstractTree for Identifier {
|
impl AbstractTree for Identifier {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, _context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, _context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "identifier", node)?;
|
SyntaxError::expect_syntax_node(source, "identifier", node)?;
|
||||||
|
|
||||||
let text = &source[node.byte_range()];
|
let text = &source[node.byte_range()];
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, IndexExpression, List, Map, SourcePosition, SyntaxNode, Type,
|
AbstractTree, Format, IndexExpression, List, Map, SourcePosition, SyntaxNode, Type, Value,
|
||||||
Value,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of an index expression.
|
/// Abstract representation of an index expression.
|
||||||
@ -19,7 +18,7 @@ pub struct Index {
|
|||||||
|
|
||||||
impl AbstractTree for Index {
|
impl AbstractTree for Index {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "index", node)?;
|
SyntaxError::expect_syntax_node(source, "index", node)?;
|
||||||
|
|
||||||
let collection_node = node.child(0).unwrap();
|
let collection_node = node.child(0).unwrap();
|
||||||
let collection = IndexExpression::from_syntax(collection_node, source, context)?;
|
let collection = IndexExpression::from_syntax(collection_node, source, context)?;
|
||||||
|
@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, AssignmentOperator, Error, Format, Index, IndexExpression, Map, Statement,
|
AbstractTree, AssignmentOperator, Format, Index, IndexExpression, Map, Statement, SyntaxNode,
|
||||||
SyntaxNode, Type, Value,
|
Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
@ -15,7 +15,7 @@ pub struct IndexAssignment {
|
|||||||
|
|
||||||
impl AbstractTree for IndexAssignment {
|
impl AbstractTree for IndexAssignment {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "index_assignment", node)?;
|
SyntaxError::expect_syntax_node(source, "index_assignment", node)?;
|
||||||
|
|
||||||
let index_node = node.child(0).unwrap();
|
let index_node = node.child(0).unwrap();
|
||||||
let index = Index::from_syntax(index_node, source, context)?;
|
let index = Index::from_syntax(index_node, source, context)?;
|
||||||
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
value_node::ValueNode,
|
value_node::ValueNode,
|
||||||
AbstractTree, Error, Format, FunctionCall, Identifier, Index, Map, SyntaxNode, Type, Value,
|
AbstractTree, Format, FunctionCall, Identifier, Index, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
@ -16,7 +16,7 @@ pub enum IndexExpression {
|
|||||||
|
|
||||||
impl AbstractTree for IndexExpression {
|
impl AbstractTree for IndexExpression {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "index_expression", node)?;
|
SyntaxError::expect_syntax_node(source, "index_expression", node)?;
|
||||||
|
|
||||||
let first_child = node.child(0).unwrap();
|
let first_child = node.child(0).unwrap();
|
||||||
let child = if first_child.is_named() {
|
let child = if first_child.is_named() {
|
||||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Expression, Format, LogicOperator, Map, SyntaxNode, Type, Value,
|
AbstractTree, Expression, Format, LogicOperator, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of a logic expression.
|
/// Abstract representation of a logic expression.
|
||||||
@ -15,7 +15,7 @@ pub struct Logic {
|
|||||||
|
|
||||||
impl AbstractTree for Logic {
|
impl AbstractTree for Logic {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "logic", node)?;
|
SyntaxError::expect_syntax_node(source, "logic", node)?;
|
||||||
|
|
||||||
let first_node = node.child(0).unwrap();
|
let first_node = node.child(0).unwrap();
|
||||||
let (left_node, operator_node, right_node) = {
|
let (left_node, operator_node, right_node) = {
|
||||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, Map, SyntaxNode, Type, Value,
|
AbstractTree, Format, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
@ -19,7 +19,7 @@ pub enum LogicOperator {
|
|||||||
|
|
||||||
impl AbstractTree for LogicOperator {
|
impl AbstractTree for LogicOperator {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, _context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, _context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "logic_operator", node)?;
|
SyntaxError::expect_syntax_node(source, "logic_operator", node)?;
|
||||||
|
|
||||||
let operator_node = node.child(0).unwrap();
|
let operator_node = node.child(0).unwrap();
|
||||||
let operator = match operator_node.kind() {
|
let operator = match operator_node.kind() {
|
||||||
|
@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Expression, Format, Map, Statement, SyntaxNode, Type, Value,
|
AbstractTree, Expression, Format, Map, Statement, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of a match statement.
|
/// Abstract representation of a match statement.
|
||||||
@ -19,7 +19,7 @@ pub struct Match {
|
|||||||
|
|
||||||
impl AbstractTree for Match {
|
impl AbstractTree for Match {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "match", node)?;
|
SyntaxError::expect_syntax_node(source, "match", node)?;
|
||||||
|
|
||||||
let matcher_node = node.child(1).unwrap();
|
let matcher_node = node.child(1).unwrap();
|
||||||
let matcher = Expression::from_syntax(matcher_node, source, context)?;
|
let matcher = Expression::from_syntax(matcher_node, source, context)?;
|
||||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Expression, Format, Map, MathOperator, SyntaxNode, Type, Value,
|
AbstractTree, Expression, Format, Map, MathOperator, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of a math operation.
|
/// Abstract representation of a math operation.
|
||||||
@ -18,7 +18,7 @@ pub struct Math {
|
|||||||
|
|
||||||
impl AbstractTree for Math {
|
impl AbstractTree for Math {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "math", node)?;
|
SyntaxError::expect_syntax_node(source, "math", node)?;
|
||||||
|
|
||||||
let left_node = node.child(0).unwrap();
|
let left_node = node.child(0).unwrap();
|
||||||
let left = Expression::from_syntax(left_node, source, context)?;
|
let left = Expression::from_syntax(left_node, source, context)?;
|
||||||
|
@ -46,7 +46,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
Error, Map, SyntaxNode, Value,
|
Map, SyntaxNode, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
@ -82,7 +82,7 @@ pub struct Root {
|
|||||||
// top-level statements in the tree.
|
// top-level statements in the tree.
|
||||||
impl AbstractTree for Root {
|
impl AbstractTree for Root {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "root", node)?;
|
SyntaxError::expect_syntax_node(source, "root", node)?;
|
||||||
|
|
||||||
let statement_count = node.child_count();
|
let statement_count = node.child_count();
|
||||||
let mut statements = Vec::with_capacity(statement_count);
|
let mut statements = Vec::with_capacity(statement_count);
|
||||||
|
@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Assignment, Block, Error, Expression, For, Format, IfElse, IndexAssignment, Map,
|
AbstractTree, Assignment, Block, Expression, For, Format, IfElse, IndexAssignment, Map, Match,
|
||||||
Match, SyntaxNode, Type, Value, While,
|
SyntaxNode, Type, Value, While,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of a statement.
|
/// Abstract representation of a statement.
|
||||||
@ -22,7 +22,7 @@ pub enum Statement {
|
|||||||
|
|
||||||
impl AbstractTree for Statement {
|
impl AbstractTree for Statement {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "statement", node)?;
|
SyntaxError::expect_syntax_node(source, "statement", node)?;
|
||||||
|
|
||||||
let child = node.child(0).unwrap();
|
let child = node.child(0).unwrap();
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, Identifier, Map, Structure, SyntaxNode, Value,
|
AbstractTree, Format, Identifier, Map, Structure, SyntaxNode, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
@ -127,7 +127,7 @@ impl Type {
|
|||||||
|
|
||||||
impl AbstractTree for Type {
|
impl AbstractTree for Type {
|
||||||
fn from_syntax(node: SyntaxNode, _source: &str, _context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, _source: &str, _context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(_source, "type", node)?;
|
SyntaxError::expect_syntax_node(_source, "type", node)?;
|
||||||
|
|
||||||
let type_node = node.child(0).unwrap();
|
let type_node = node.child(0).unwrap();
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Error, Format, Map, SyntaxNode, Type, Value,
|
AbstractTree, Format, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
|
||||||
@ -26,7 +26,7 @@ impl TypeSpecification {
|
|||||||
|
|
||||||
impl AbstractTree for TypeSpecification {
|
impl AbstractTree for TypeSpecification {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "type_specification", node)?;
|
SyntaxError::expect_syntax_node(source, "type_specification", node)?;
|
||||||
|
|
||||||
let type_node = node.child(1).unwrap();
|
let type_node = node.child(1).unwrap();
|
||||||
let r#type = Type::from_syntax(type_node, source, context)?;
|
let r#type = Type::from_syntax(type_node, source, context)?;
|
||||||
|
@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, BuiltInValue, Error, Expression, Format, Function, FunctionNode, Identifier,
|
AbstractTree, BuiltInValue, Expression, Format, Function, FunctionNode, Identifier, List, Map,
|
||||||
List, Map, Statement, Structure, SyntaxNode, Type, TypeSpecification, Value,
|
Statement, Structure, SyntaxNode, Type, TypeSpecification, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq)]
|
||||||
@ -25,7 +25,7 @@ pub enum ValueNode {
|
|||||||
|
|
||||||
impl AbstractTree for ValueNode {
|
impl AbstractTree for ValueNode {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "value", node)?;
|
SyntaxError::expect_syntax_node(source, "value", node)?;
|
||||||
|
|
||||||
let child = node.child(0).unwrap();
|
let child = node.child(0).unwrap();
|
||||||
let value_node = match child.kind() {
|
let value_node = match child.kind() {
|
||||||
|
@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
AbstractTree, Block, Error, Expression, Format, Map, SyntaxNode, Type, Value,
|
AbstractTree, Block, Expression, Format, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of a while loop.
|
/// Abstract representation of a while loop.
|
||||||
@ -16,7 +16,7 @@ pub struct While {
|
|||||||
|
|
||||||
impl AbstractTree for While {
|
impl AbstractTree for While {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "while", node)?;
|
SyntaxError::expect_syntax_node(source, "while", node)?;
|
||||||
|
|
||||||
let expression_node = node.child(1).unwrap();
|
let expression_node = node.child(1).unwrap();
|
||||||
let expression = Expression::from_syntax(expression_node, source, context)?;
|
let expression = Expression::from_syntax(expression_node, source, context)?;
|
||||||
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use crate::{
|
use crate::{
|
||||||
error::{RuntimeError, SyntaxError, ValidationError},
|
error::{RuntimeError, SyntaxError, ValidationError},
|
||||||
function_expression::FunctionExpression,
|
function_expression::FunctionExpression,
|
||||||
AbstractTree, Error, Expression, Format, FunctionCall, Map, SyntaxNode, Type, Value,
|
AbstractTree, Expression, Format, FunctionCall, Map, SyntaxNode, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Abstract representation of a yield expression.
|
/// Abstract representation of a yield expression.
|
||||||
@ -16,7 +16,7 @@ pub struct Yield {
|
|||||||
|
|
||||||
impl AbstractTree for Yield {
|
impl AbstractTree for Yield {
|
||||||
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
fn from_syntax(node: SyntaxNode, source: &str, context: &Map) -> Result<Self, SyntaxError> {
|
||||||
Error::expect_syntax_node(source, "yield", node)?;
|
SyntaxError::expect_syntax_node(source, "yield", node)?;
|
||||||
|
|
||||||
let input_node = node.child(0).unwrap();
|
let input_node = node.child(0).unwrap();
|
||||||
let input = Expression::from_syntax(input_node, source, context)?;
|
let input = Expression::from_syntax(input_node, source, context)?;
|
||||||
|
@ -11,12 +11,11 @@ pub use runtime_error::RuntimeError;
|
|||||||
pub use syntax_error::SyntaxError;
|
pub use syntax_error::SyntaxError;
|
||||||
pub use validation_error::ValidationError;
|
pub use validation_error::ValidationError;
|
||||||
|
|
||||||
use tree_sitter::{LanguageError, Node, Point};
|
use tree_sitter::{LanguageError, Point};
|
||||||
|
|
||||||
use crate::{SourcePosition};
|
|
||||||
|
|
||||||
use std::fmt::{self, Formatter};
|
use std::fmt::{self, Formatter};
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
Syntax(SyntaxError),
|
Syntax(SyntaxError),
|
||||||
|
|
||||||
@ -29,32 +28,6 @@ pub enum Error {
|
|||||||
Language(LanguageError),
|
Language(LanguageError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error {
|
|
||||||
pub fn expect_syntax_node(
|
|
||||||
source: &str,
|
|
||||||
expected: &str,
|
|
||||||
actual: Node,
|
|
||||||
) -> Result<(), SyntaxError> {
|
|
||||||
log::info!("Converting {} to abstract node", actual.kind());
|
|
||||||
|
|
||||||
if expected == actual.kind() {
|
|
||||||
Ok(())
|
|
||||||
} else if actual.is_error() {
|
|
||||||
Err(SyntaxError::InvalidSource {
|
|
||||||
source: source[actual.byte_range()].to_string(),
|
|
||||||
position: SourcePosition::from(actual.range()),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
Err(SyntaxError::UnexpectedSyntaxNode {
|
|
||||||
expected: expected.to_string(),
|
|
||||||
actual: actual.kind().to_string(),
|
|
||||||
location: actual.start_position(),
|
|
||||||
relevant_source: source[actual.byte_range()].to_string(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<SyntaxError> for Error {
|
impl From<SyntaxError> for Error {
|
||||||
fn from(error: SyntaxError) -> Self {
|
fn from(error: SyntaxError) -> Self {
|
||||||
Error::Syntax(error)
|
Error::Syntax(error)
|
||||||
|
@ -3,23 +3,24 @@ use std::{
|
|||||||
io,
|
io,
|
||||||
num::ParseFloatError,
|
num::ParseFloatError,
|
||||||
string::FromUtf8Error,
|
string::FromUtf8Error,
|
||||||
time::{self, SystemTimeError},
|
time,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{Value};
|
use crate::Value;
|
||||||
|
|
||||||
use super::rw_lock_error::RwLockError;
|
use super::rw_lock_error::RwLockError;
|
||||||
|
|
||||||
|
#[derive(PartialEq)]
|
||||||
pub enum RuntimeError {
|
pub enum RuntimeError {
|
||||||
Csv(csv::Error),
|
Csv(String),
|
||||||
|
|
||||||
Io(io::Error),
|
Io(String),
|
||||||
|
|
||||||
Reqwest(reqwest::Error),
|
Reqwest(String),
|
||||||
|
|
||||||
Json(serde_json::Error),
|
Json(String),
|
||||||
|
|
||||||
SystemTime(SystemTimeError),
|
SystemTime(String),
|
||||||
|
|
||||||
Toml(toml::de::Error),
|
Toml(toml::de::Error),
|
||||||
|
|
||||||
@ -128,31 +129,31 @@ impl RuntimeError {
|
|||||||
|
|
||||||
impl From<csv::Error> for RuntimeError {
|
impl From<csv::Error> for RuntimeError {
|
||||||
fn from(error: csv::Error) -> Self {
|
fn from(error: csv::Error) -> Self {
|
||||||
RuntimeError::Csv(error)
|
RuntimeError::Csv(error.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<io::Error> for RuntimeError {
|
impl From<io::Error> for RuntimeError {
|
||||||
fn from(error: std::io::Error) -> Self {
|
fn from(error: std::io::Error) -> Self {
|
||||||
RuntimeError::Io(error)
|
RuntimeError::Io(error.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<reqwest::Error> for RuntimeError {
|
impl From<reqwest::Error> for RuntimeError {
|
||||||
fn from(error: reqwest::Error) -> Self {
|
fn from(error: reqwest::Error) -> Self {
|
||||||
RuntimeError::Reqwest(error)
|
RuntimeError::Reqwest(error.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<serde_json::Error> for RuntimeError {
|
impl From<serde_json::Error> for RuntimeError {
|
||||||
fn from(error: serde_json::Error) -> Self {
|
fn from(error: serde_json::Error) -> Self {
|
||||||
RuntimeError::Json(error)
|
RuntimeError::Json(error.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<time::SystemTimeError> for RuntimeError {
|
impl From<time::SystemTimeError> for RuntimeError {
|
||||||
fn from(error: time::SystemTimeError) -> Self {
|
fn from(error: time::SystemTimeError) -> Self {
|
||||||
RuntimeError::SystemTime(error)
|
RuntimeError::SystemTime(error.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tree_sitter::Point;
|
use tree_sitter::{Node as SyntaxNode, Point};
|
||||||
|
|
||||||
use crate::SourcePosition;
|
use crate::SourcePosition;
|
||||||
|
|
||||||
@ -26,6 +26,32 @@ pub enum SyntaxError {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SyntaxError {
|
||||||
|
pub fn expect_syntax_node(
|
||||||
|
source: &str,
|
||||||
|
expected: &str,
|
||||||
|
actual: SyntaxNode,
|
||||||
|
) -> Result<(), SyntaxError> {
|
||||||
|
log::info!("Converting {} to abstract node", actual.kind());
|
||||||
|
|
||||||
|
if expected == actual.kind() {
|
||||||
|
Ok(())
|
||||||
|
} else if actual.is_error() {
|
||||||
|
Err(SyntaxError::InvalidSource {
|
||||||
|
source: source[actual.byte_range()].to_string(),
|
||||||
|
position: SourcePosition::from(actual.range()),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(SyntaxError::UnexpectedSyntaxNode {
|
||||||
|
expected: expected.to_string(),
|
||||||
|
actual: actual.kind().to_string(),
|
||||||
|
location: actual.start_position(),
|
||||||
|
relevant_source: source[actual.byte_range()].to_string(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<RwLockError> for SyntaxError {
|
impl From<RwLockError> for SyntaxError {
|
||||||
fn from(error: RwLockError) -> Self {
|
fn from(error: RwLockError) -> Self {
|
||||||
SyntaxError::RwLock(error)
|
SyntaxError::RwLock(error)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use dust_lang::*;
|
use dust_lang::{error::ValidationError, *};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_assignment() {
|
fn simple_assignment() {
|
||||||
@ -39,8 +39,19 @@ fn list_add_wrong_type() {
|
|||||||
",
|
",
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(result.unwrap_err().is_error(&Error::TypeCheck {
|
assert_eq!(
|
||||||
expected: Type::String,
|
Err(Error::Validation(ValidationError::TypeCheck {
|
||||||
actual: Type::Integer
|
expected: Type::String,
|
||||||
}))
|
actual: Type::Integer,
|
||||||
|
position: SourcePosition {
|
||||||
|
start_byte: 0,
|
||||||
|
end_byte: 0,
|
||||||
|
start_row: 0,
|
||||||
|
start_column: 0,
|
||||||
|
end_row: 0,
|
||||||
|
end_column: 0
|
||||||
|
}
|
||||||
|
})),
|
||||||
|
result
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use dust_lang::*;
|
use dust_lang::{error::ValidationError, *};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_call() {
|
fn function_call() {
|
||||||
@ -48,14 +48,18 @@ fn built_in_function_call() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_context_does_not_capture_normal_values() {
|
fn function_context_does_not_capture_normal_values() {
|
||||||
assert!(interpret(
|
assert_eq!(
|
||||||
"
|
interpret(
|
||||||
|
"
|
||||||
x = 1
|
x = 1
|
||||||
|
|
||||||
foo = () <any> { x }
|
foo = () <any> { x }
|
||||||
"
|
"
|
||||||
)
|
),
|
||||||
.is_err_and(|error| error.is_error(&Error::VariableIdentifierNotFound("x".to_string()))));
|
Err(Error::Validation(
|
||||||
|
ValidationError::VariableIdentifierNotFound(Identifier::new("x".to_string()))
|
||||||
|
))
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
interpret(
|
interpret(
|
||||||
|
@ -1,13 +1,24 @@
|
|||||||
use dust_lang::*;
|
use dust_lang::{error::ValidationError, *};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn simple_type_check() {
|
fn simple_type_check() {
|
||||||
let result = interpret("x <bool> = 1");
|
let result = interpret("x <bool> = 1");
|
||||||
|
|
||||||
assert!(result.unwrap_err().is_error(&Error::TypeCheck {
|
assert_eq!(
|
||||||
expected: Type::Boolean,
|
Err(Error::Validation(ValidationError::TypeCheck {
|
||||||
actual: Type::Integer
|
expected: Type::Boolean,
|
||||||
}));
|
actual: Type::Integer,
|
||||||
|
position: SourcePosition {
|
||||||
|
start_byte: 0,
|
||||||
|
end_byte: 0,
|
||||||
|
start_row: 0,
|
||||||
|
start_column: 0,
|
||||||
|
end_row: 0,
|
||||||
|
end_column: 0,
|
||||||
|
}
|
||||||
|
})),
|
||||||
|
result
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -37,14 +48,25 @@ fn callback_type_check() {
|
|||||||
",
|
",
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(result.unwrap_err().is_error(&Error::TypeCheck {
|
assert_eq!(
|
||||||
expected: Type::Function {
|
Err(Error::Validation(ValidationError::TypeCheck {
|
||||||
parameter_types: vec![],
|
expected: Type::Function {
|
||||||
return_type: Box::new(Type::Boolean),
|
parameter_types: vec![],
|
||||||
},
|
return_type: Box::new(Type::Boolean),
|
||||||
actual: Type::Function {
|
},
|
||||||
parameter_types: vec![],
|
actual: Type::Function {
|
||||||
return_type: Box::new(Type::Integer),
|
parameter_types: vec![],
|
||||||
},
|
return_type: Box::new(Type::Integer),
|
||||||
}));
|
},
|
||||||
|
position: SourcePosition {
|
||||||
|
start_byte: 0,
|
||||||
|
end_byte: 0,
|
||||||
|
start_row: 0,
|
||||||
|
start_column: 0,
|
||||||
|
end_row: 0,
|
||||||
|
end_column: 0
|
||||||
|
}
|
||||||
|
})),
|
||||||
|
result
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -99,12 +99,21 @@ fn map_types() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn map_type_errors() {
|
fn map_type_errors() {
|
||||||
assert!(interpret("{ foo <bool> = 'bar' }")
|
assert_eq!(
|
||||||
.unwrap_err()
|
interpret("{ foo <bool> = 'bar' }"),
|
||||||
.is_error(&Error::TypeCheck {
|
Err(Error::Validation(error::ValidationError::TypeCheck {
|
||||||
expected: Type::Boolean,
|
expected: Type::Boolean,
|
||||||
actual: Type::String
|
actual: Type::String,
|
||||||
|
position: SourcePosition {
|
||||||
|
start_byte: 0,
|
||||||
|
end_byte: 0,
|
||||||
|
start_row: 0,
|
||||||
|
start_column: 0,
|
||||||
|
end_row: 0,
|
||||||
|
end_column: 0
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user