From cbf3b6d4a56a89ed5f53c944db6b3065770d43a7 Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Thu, 19 Mar 2020 11:48:30 +0100 Subject: [PATCH] fix error reporting when printing void --- alib2cli/src/ast/command/PrintCommand.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/alib2cli/src/ast/command/PrintCommand.h b/alib2cli/src/ast/command/PrintCommand.h index 3266f095af..d2c3350f00 100644 --- a/alib2cli/src/ast/command/PrintCommand.h +++ b/alib2cli/src/ast/command/PrintCommand.h @@ -20,6 +20,9 @@ public: CommandResult run ( Environment & environment ) const override { std::shared_ptr < abstraction::Value > value = m_expr->translateAndEval ( environment ); + if ( value->getType ( ) == std::string ( ext::to_string < void > ( ) ) ) + throw std::invalid_argument ( "Printing void is not allowed." ); + std::shared_ptr < abstraction::OperationAbstraction > res = abstraction::Registry::getValuePrinterAbstraction ( value->getType ( ) ); res->attachInput ( value, 0 ); -- GitLab