Re: Const object variant issue

2020-07-11 Thread geotre
Yeah if it's going to be added to the compiler then that's great. Those workarounds don't work in my use case but I've just simplified things to remove the case statement

Re: Const object variant issue

2020-07-11 Thread mratsim
> It looks like this isn't supposed to work and should be flagged by the > compiler. It's more like it was a use-case that was missed and should be added to the compiler. Current workarounds: * Use `let` instead of const: [https://github.com/status-im/nimbus/blob/bfd71130/nimbus/vm/interpre

Re: Const object variant issue

2020-07-11 Thread geotre
Thanks @mratsim for pointing me to those issues! I did not find them before. It looks like this isn't supposed to work and should be flagged by the compiler. @shirleyquirk thank you for also looking into the issue. I had tried that but with my object init proc it only works if the procedure is a

Re: Const object variant issue

2020-07-09 Thread shirleyquirk
looking at the generated C code this is definitely a bug when root is instantiated _[both](https://forum.nim-lang.org/postActivity.xml#both) root.value and root.children are initialized if root.value is set to 0 after root.children has been set, it overwrites the seq pointer which isn't great,

Re: Const object variant issue

2020-07-09 Thread mratsim
Known issue: [https://github.com/nim-lang/Nim/issues/13081](https://github.com/nim-lang/Nim/issues/13081) And linked: * [https://github.com/nim-lang/Nim/issues/8015](https://github.com/nim-lang/Nim/issues/8015) * [https://github.com/nim-lang/Nim/issues/8007](https://github.com/nim-lang/Nim

Re: Const object variant issue

2020-07-09 Thread shirleyquirk
i don't know what's going on either, but swapping A and B: Node = object case kind: NodeKind of B: value: int of A: children: seq[Node] Run works

Const object variant issue

2020-07-09 Thread geotre
I'm getting some odd behavior that I don't understand. I've simplified it down to this example: type NodeKind = enum A, B Node = object case kind: NodeKind of A: children: seq[Node] of B: value: int # < this line