@@ -67,7 +67,7 @@ function processes_to_mtkmodel(_processes::Vector, default::Dict{Num, Any};
6767 # Setup: obtain lhs-variables so we can track new variables that are not
6868 # in this vector. The vector has to be of type `Num`
6969 lhs_vars = Num[lhs_variable (p) for p in processes]
70- ensure_unique_vars (lhs_vars)
70+ ensure_unique_vars (lhs_vars, processes )
7171 # First pass: generate equations from given processes
7272 # and collect variables without equations
7373 incomplete = Num[]
@@ -76,7 +76,7 @@ function processes_to_mtkmodel(_processes::Vector, default::Dict{Num, Any};
7676 for proc in processes
7777 append_incomplete_variables! (incomplete, introduced, lhs_vars, proc)
7878 # add the generated equation in the pool of equations
79- push! (eqs, lhs (proc) ~ rhs (proc))
79+ push! (eqs, equation (proc))
8080 end
8181 # Second pass: attempt to add default processes to incomplete variables
8282 # throw an error if default does not exist
@@ -169,9 +169,22 @@ function append_incomplete_variables!(incomplete, introduced, lhs_vars, process)
169169 return
170170end
171171
172- function ensure_unique_vars (lhs_vars)
172+ function ensure_unique_vars (lhs_vars, processes )
173173 nonun = nonunique (lhs_vars)
174- isempty (nonun) || error (" The following variables have more than one processes assigned to them: $(nonun) " )
174+ isempty (nonun) && return # all good!
175+ dupprocs = []
176+ for var in nonun
177+ idxs = findall (p -> Symbol (lhs_variable (p)) == Symbol (var), processes)
178+ append! (dupprocs, processes[idxs])
179+ end
180+ errormsg = """
181+ The following variables have more than one processes assigned to them: $(nonun) .
182+ The duplicate processes are:
183+ """
184+ for p in dupprocs
185+ errormsg *= " \n " * sprint (show, p)
186+ end
187+ throw (ArgumentError (errormsg))
175188 return
176189end
177190
0 commit comments