Type mismatch when trying to add to custom seq

2023-08-25 Thread snorlax14
Right, I see. Thanks for the explanation :)

Type mismatch when trying to add to custom seq

2023-08-25 Thread PMunch
It's a subtle bug, but essentially your object isn't mutable, so the sequence isn't mutable. The type error is because it's `seq[Terminal]` and `add` requires a `var seq[Terminal]`. Replacing `schematicConnect` with this works: proc schematicConnect(schematic: var Schematic, termina

Type mismatch when trying to add to custom seq

2023-08-25 Thread pp
Works using intermediate variables (and one var in proc definition):

Type mismatch when trying to add to custom seq

2023-08-25 Thread snorlax14
Tried to reconstruct it using your playground but it doesn't produce the same error so here's the exact code. Sorry if it's a bit unreadable :/

Type mismatch when trying to add to custom seq

2023-08-25 Thread pp
This works for me trying to reconstruct missing parts:

Type mismatch when trying to add to custom seq

2023-08-25 Thread snorlax14
`adjacencyList.connections.add(terminal)` is the exact line that causes the error. `adjacencyList` is a `seq[Terminal]` and terminal has type `Terminal`

Type mismatch when trying to add to custom seq

2023-08-25 Thread xigoi
Can you provide an example of the code where you're adding to a sequence?

Type mismatch when trying to add to custom seq

2023-08-25 Thread snorlax14
I've defined a custom type in my nim script, here's the definition: type Terminal = tuple name: string terminalType: TerminalType # enum defined elsewhere in the program parentComponent: ref Component # type defined elsewhere in the progra