Skip to content

Commit

Permalink
improving error message: case assignment to signal of not initialized…
Browse files Browse the repository at this point in the history
… component
  • Loading branch information
clararod9 committed Jan 11, 2024
1 parent 12c92e0 commit 2ce3420
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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));
Expand Down
8 changes: 8 additions & 0 deletions constraint_generation/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -2313,6 +2317,10 @@ fn treat_result_with_memory_error<C>(
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(
Expand Down
3 changes: 2 additions & 1 deletion program_structure/src/utils/memory_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ pub enum TypeInvalidAccess{

pub enum TypeAssignmentError{
MultipleAssignments,
AssignmentOutput
AssignmentOutput,
NoInitializedComponent
}

pub enum MemoryError {
Expand Down

0 comments on commit 2ce3420

Please sign in to comment.