diff --git a/src/protocol/ast.rs b/src/protocol/ast.rs index d252810ebdbe8cd7fc9266f18c237d2cb10fc5e3..1c85a558741dd335dee6f3e89d60059b29e3ae9f 100644 --- a/src/protocol/ast.rs +++ b/src/protocol/ast.rs @@ -404,8 +404,7 @@ impl ParserTypeVariant { #[derive(Debug, Clone)] pub struct ParserTypeElement { - // TODO: @cleanup, do we ever need the span of a user-defined type after - // constructing it? + // TODO: @Fix span pub full_span: InputSpan, // full span of type, including any polymorphic arguments pub variant: ParserTypeVariant, } @@ -1667,10 +1666,6 @@ pub enum UnaryOperator { Negative, BitwiseNot, LogicalNot, - PreIncrement, - PreDecrement, - PostIncrement, - PostDecrement, } #[derive(Debug, Clone)] diff --git a/src/protocol/eval/value.rs b/src/protocol/eval/value.rs index efbba361c6c6e4f6f9de09d26edf2b80cfaeaa5e..0f8dd46cbe48ed7d5afd0fadff97de3c50bd0b26 100644 --- a/src/protocol/eval/value.rs +++ b/src/protocol/eval/value.rs @@ -493,10 +493,6 @@ pub(crate) fn apply_unary_operator(store: &mut Store, op: UnaryOperator, value: }, UO::BitwiseNot => { apply_int_expr_and_return!(value, !, op)}, UO::LogicalNot => { return Value::Bool(!value.as_bool()); }, - UO::PreIncrement => { todo!("implement") }, - UO::PreDecrement => { todo!("implement") }, - UO::PostIncrement => { todo!("implement") }, - UO::PostDecrement => { todo!("implement") }, } } diff --git a/src/protocol/parser/pass_definitions.rs b/src/protocol/parser/pass_definitions.rs index ba7a121d98236cff29efc65b55ad3e9b09b9ae12..fe2d9987f3574bfeadab97f9ba488a261122ac89 100644 --- a/src/protocol/parser/pass_definitions.rs +++ b/src/protocol/parser/pass_definitions.rs @@ -1128,24 +1128,34 @@ impl PassDefinitions { match token { Some(TK::Plus) => Some(UO::Positive), Some(TK::Minus) => Some(UO::Negative), - Some(TK::PlusPlus) => Some(UO::PreIncrement), - Some(TK::MinusMinus) => Some(UO::PreDecrement), Some(TK::Tilde) => Some(UO::BitwiseNot), Some(TK::Exclamation) => Some(UO::LogicalNot), _ => None } } - if let Some(operation) = parse_prefix_token(iter.next()) { + let next = iter.next(); + if let Some(operation) = parse_prefix_token(next) { let span = iter.next_span(); iter.consume(); let expression = self.consume_prefix_expression(module, iter, ctx)?; Ok(ctx.heap.alloc_unary_expression(|this| UnaryExpression { - this, span, operation, expression, + this, + span, + operation, + expression, parent: ExpressionParent::None, unique_id_in_definition: -1, }).upcast()) + } else if next == Some(TokenKind::PlusPlus) { + return Err(ParseError::new_error_str_at_span( + &module.source, iter.next_span(), "prefix increment is not supported in the language" + )); + } else if next == Some(TokenKind::MinusMinus) { + return Err(ParseError::new_error_str_at_span( + &module.source, iter.next_span(), "prefix decrement is not supported in this language" + )); } else { self.consume_postfix_expression(module, iter, ctx) } @@ -1172,21 +1182,13 @@ impl PassDefinitions { iter.consume(); if token == TokenKind::PlusPlus { - result = ctx.heap.alloc_unary_expression(|this| UnaryExpression{ - this, span, - operation: UnaryOperator::PostIncrement, - expression: result, - parent: ExpressionParent::None, - unique_id_in_definition: -1, - }).upcast(); + return Err(ParseError::new_error_str_at_span( + &module.source, span, "postfix increment is not supported in this language" + )); } else if token == TokenKind::MinusMinus { - result = ctx.heap.alloc_unary_expression(|this| UnaryExpression{ - this, span, - operation: UnaryOperator::PostDecrement, - expression: result, - parent: ExpressionParent::None, - unique_id_in_definition: -1, - }).upcast(); + return Err(ParseError::new_error_str_at_span( + &module.source, span, "prefix increment is not supported in this language" + )); } else if token == TokenKind::OpenSquare { let subject = result; let from_index = self.consume_expression(module, iter, ctx)?; diff --git a/src/protocol/parser/pass_typing.rs b/src/protocol/parser/pass_typing.rs index 20bf5dab7e22922e63dfcf8624e8d0b7aa1254fe..26a9543b7881db7df3230332507a112d7d9f3ac0 100644 --- a/src/protocol/parser/pass_typing.rs +++ b/src/protocol/parser/pass_typing.rs @@ -1829,7 +1829,7 @@ impl PassTyping { (progress_base || progress_expr, progress_base || progress_arg) }, - UO::BitwiseNot | UO::PreIncrement | UO::PreDecrement | UO::PostIncrement | UO::PostDecrement => { + UO::BitwiseNot => { // Equal types of integer class let progress_base = self.apply_template_constraint(ctx, upcast_id, &INTEGERLIKE_TEMPLATE)?; let (progress_expr, progress_arg) =