I just found an error that I did not encounter before:
nim "Error: type mismatch: got <End>"
I tried to find some info online but I did not find any info about this. What does it mean that the type is "<End>"?
I think I've found the source of the problem, but I also think that there is a problem with error that is being reported.
This is a minimal example that reproduces the issue:
# std imports
import sequtils
# External imports
import docopt # Command line parser (adds pcre64.dll dependency)
import plotly
import chroma
proc main() =
let num_signals: int = 2
var data_length: uint = 0
var data_samples = newSeqWith(num_signals, newSeq[int16](data_length))
var d = Trace[int](mode: PlotMode.Lines, `type`: PlotType.Scatter)
d.ys = data_samples[0]
var layout = Layout(title: "testing", width: 1200, height: 400,
xaxis: Axis(title:"my x-axis"),
yaxis: Axis(title: "y-axis too"),
autosize: false)
var p = Plot[int](layout:layout, traces: @[d])
p.show()
main()
Compiling this program (saved as plot.nim, and using the plotly and docopt libraries) I get the following strange error:
plot.nim(17, 24) Error: type mismatch: got <End> but expected 'seq[int]'
If I remove the "import doctopt" line (which in this minimum example is unnecessary, but is needed in the real program) this is what is left:
# std imports
import sequtils
# External imports
import plotly
import chroma
proc main() =
let num_signals: int = 2
var data_length: uint = 0
var data_samples = newSeqWith(num_signals, newSeq[int16](data_length))
var d = Trace[int](mode: PlotMode.Lines, `type`: PlotType.Scatter)
d.ys = data_samples[0]
var layout = Layout(title: "testing", width: 1200, height: 400,
xaxis: Axis(title:"my x-axis"),
yaxis: Axis(title: "y-axis too"),
autosize: false)
var p = Plot[int](layout:layout, traces: @[d])
p.show()
main()
Compiling this new version I get a different, much better error that points out to the real problem:
plot.nim(16, 24) Error: type mismatch: got <seq[int16]> but expected 'seq[int]'
So the root cause of the error was that I was mixing int16 and int sequences. However, the error message is wrong, so this seems like a compiler error or a weird problem with the docopt library which is not doing anything in this small example?
docopt imports regex imports regex/nfatype imports regex/litop which defines
type
End = seq[int16]
Thank you, I understand now. That being said, wouldn’t it make more sense if the error message referred to the actual type of the variable that did not match the expected type?
Also, the fact that the expected type is printed between a pair of back quotes while the actual type is printed between < and > is pretty confusing, I think.