I have a strange error with the following program:
import sequtils
proc luDecomposition(n: int) =
# Créer des matrices L et U
var lower, upper: seq[seq[float]] = newSeqWith(n, newSeq[float](n))
# Exemple d'utilisation
let n = 3
luDecomposition(n)
Hint: used config file '/home/kolmogorov/.choosenim/toolchains/nim-2.0.0/config/nim.cfg' [Conf]
Hint: used config file '/home/kolmogorov/.choosenim/toolchains/nim-2.0.0/config/config.nims' [Conf]
............................................................................
CC: lu_factorisation.nim
/home/kolmogorov/.cache/nim/lu_factorisation_d/@mlu_factorisation.nim.c: In function ‘luDecomposition__lu95factorisation_u3’:
/home/kolmogorov/.cache/nim/lu_factorisation_d/@mlu_factorisation.nim.c:176:45: error: redeclaration of ‘resultX60gensym0_’ with no linkage
176 | tySequence__Is9bsejK6Dzx0wAHnaSKL3Q resultX60gensym0_;
| ^~~~~~~~~~~~~~~~~
/home/kolmogorov/.cache/nim/lu_factorisation_d/@mlu_factorisation.nim.c:174:45: note: previous declaration of ‘resultX60gensym0_’ with type ‘tySequence__Is9bsejK6Dzx0wAHnaSKL3Q’
174 | tySequence__Is9bsejK6Dzx0wAHnaSKL3Q resultX60gensym0_;
| ^~~~~~~~~~~~~~~~~
/home/kolmogorov/.cache/nim/lu_factorisation_d/@mlu_factorisation.nim.c:180:12: error: redeclaration of ‘newLenX60gensym0_’ with no linkage
180 | NI newLenX60gensym0_;
| ^~~~~~~~~~~~~~~~~
/home/kolmogorov/.cache/nim/lu_factorisation_d/@mlu_factorisation.nim.c:179:12: note: previous declaration of ‘newLenX60gensym0_’ with type ‘NI’ {aka ‘long int’}
179 | NI newLenX60gensym0_;
| ^~~~~~~~~~~~~~~~~
Error: execution of an external compiler program 'gcc -c -w -fmax-errors=3 -pthread -I/home/kolmogorov/.choosenim/toolchains/nim-2.0.0/lib -I/home/kolmogorov -o /home/kolmogorov/.cache/nim/lu_factorisation_d/@mlu_factorisation.nim.c.o /home/kolmogorov/.cache/nim/lu_factorisation_d/@mlu_factorisation.nim.c' failed with exit code: 1
Could you tell me what is the cause of the error (Is this a double reference issue?). What would be the correct way to initialize matrices here?Thanks! I want to create two separate sequences. I guess this would be more clearer for the compiler:
var (lower, upper) = (newSeqWith(n, newSeq[float](n)), newSeqWith(n, newSeq[float](n)))
Before I raise an issue in the Nim repository, I would like to understand this inconsistent behavior. Why does the following code works when declared at the global level and not when declared inside a procedure?
var lower, upper = newSeqWith(n, newSeq[float](n))