Skip to content

Commit 1e54a08

Browse files
committed
fix #653, spurious error in zygosityOfMutations()
1 parent 952b0f6 commit 1e54a08

2 files changed

Lines changed: 10 additions & 7 deletions

File tree

core/individual.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6384,17 +6384,20 @@ EidosValue_SP Individual_Class::ExecuteMethod_zygosityOfMutations(EidosGlobalStr
63846384
else
63856385
{
63866386
// When assessing a vector of mutations, we first determine which chromosomes we need to scan
6387-
// In this case we also need to check that all mutations belong to the same species as the individuals
6388-
if (Community::SpeciesForMutations(mutations_value) != species)
6389-
EIDOS_TERMINATION << "ERROR (Individual_Class::ExecuteMethod_zygosityOfMutations): zygosityOfMutations() requires that all mutations belong to the same species as the target individuals." << EidosTerminate();
6387+
Mutation **mutations_data = (Mutation **)mutations_value->ObjectData();
6388+
int mutations_count = mutations_value->Count();
6389+
6390+
if (mutations_count > 0)
6391+
{
6392+
// In this case we also need to check that all mutations belong to the same species as the individuals
6393+
if (Community::SpeciesForMutations(mutations_value) != species)
6394+
EIDOS_TERMINATION << "ERROR (Individual_Class::ExecuteMethod_zygosityOfMutations): zygosityOfMutations() requires that all mutations belong to the same species as the target individuals." << EidosTerminate();
6395+
}
63906396

63916397
// zero out the scratch_ for all chromosomes; 0 indicates the chromosome is not active
63926398
for (Chromosome *chromosome : chromosomes)
63936399
chromosome->scratch_ = 0;
63946400

6395-
Mutation **mutations_data = (Mutation **)mutations_value->ObjectData();
6396-
int mutations_count = mutations_value->Count();
6397-
63986401
focalMutations.resize(mutations_count);
63996402

64006403
Mutation **focalMutations_data = focalMutations.data();

eidos/eidos_interpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6437,7 +6437,7 @@ EidosValue_SP EidosInterpreter::Evaluate_For(const EidosASTNode *p_node)
64376437
case EidosValueType::kValueString:
64386438
{
64396439
EidosValue_String *string_range_value = (EidosValue_String *)(loop_handler.range_value.get());
6440-
std::string &iterator_logical_value = string_range_value->StringData_Mutable()[range_index];
6440+
const std::string &iterator_logical_value = string_range_value->StringData()[range_index];
64416441

64426442
*(std::string *)loop_handler.iterator_data = iterator_logical_value;
64436443
break;

0 commit comments

Comments
 (0)