From 2ce34209aa3f0439ebc0a354f87b24bcd60fd039 Mon Sep 17 00:00:00 2001 From: clararod9 Date: Thu, 11 Jan 2024 12:43:40 +0100 Subject: [PATCH] improving error message: case assignment to signal of not initialized component --- .../src/environment_utils/component_representation.rs | 8 ++++++++ constraint_generation/src/execute.rs | 8 ++++++++ program_structure/src/utils/memory_slice.rs | 3 ++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/constraint_generation/src/environment_utils/component_representation.rs b/constraint_generation/src/environment_utils/component_representation.rs index 5bea92abf..3d6505466 100644 --- a/constraint_generation/src/environment_utils/component_representation.rs +++ b/constraint_generation/src/environment_utils/component_representation.rs @@ -251,6 +251,10 @@ impl ComponentRepresentation { // We copy tags in any case, complete or incomplete assignment // The values of the tags must be the same than the ones stored before + if !component.is_preinitialized() { + return Result::Err(MemoryError::AssignmentError(TypeAssignmentError::NoInitializedComponent)); + } + if !component.inputs_tags.contains_key(signal_name){ return Result::Err(MemoryError::AssignmentError(TypeAssignmentError::AssignmentOutput)); } @@ -286,6 +290,10 @@ impl ComponentRepresentation { slice_route: &[SliceCapacity], tags: TagInfo, ) -> Result<(), MemoryError> { + + if !component.is_preinitialized() { + return Result::Err(MemoryError::AssignmentError(TypeAssignmentError::NoInitializedComponent)); + } if !component.inputs.contains_key(signal_name){ return Result::Err(MemoryError::AssignmentError(TypeAssignmentError::AssignmentOutput)); diff --git a/constraint_generation/src/execute.rs b/constraint_generation/src/execute.rs index 45ed6042f..a4d085fff 100644 --- a/constraint_generation/src/execute.rs +++ b/constraint_generation/src/execute.rs @@ -2214,6 +2214,10 @@ fn treat_result_with_memory_error_void( Report::error("Exception caused by invalid assignment: trying to assign a value to an output signal of a component".to_string(), RuntimeError) }, + TypeAssignmentError::NoInitializedComponent =>{ + Report::error("Exception caused by invalid assignment: trying to assign a value to a signal of a component that has not been initialized".to_string(), + RuntimeError) + } } }, MemoryError::OutOfBoundsError => { @@ -2313,6 +2317,10 @@ fn treat_result_with_memory_error( Report::error("Exception caused by invalid assignment: trying to assign a value to an output signal of a component".to_string(), RuntimeError) }, + TypeAssignmentError::NoInitializedComponent =>{ + Report::error("Exception caused by invalid assignment: trying to assign a value to a signal of a component that has not been initialized".to_string(), + RuntimeError) + } } }, MemoryError::AssignmentMissingTags(signal, tag) => Report::error( diff --git a/program_structure/src/utils/memory_slice.rs b/program_structure/src/utils/memory_slice.rs index 8a8d4f10f..12a494d14 100644 --- a/program_structure/src/utils/memory_slice.rs +++ b/program_structure/src/utils/memory_slice.rs @@ -10,7 +10,8 @@ pub enum TypeInvalidAccess{ pub enum TypeAssignmentError{ MultipleAssignments, - AssignmentOutput + AssignmentOutput, + NoInitializedComponent } pub enum MemoryError {