Re: Resolve: Error: parallel 'fields' iterator does not work for 'case' objects

2018-03-17 Thread GULPF
In the other tests you have posted you are not comparing case objects. E.g 
`boolValueAV.boolValue == boolValue` is fine because you are comparing bools, 
but `anyseqValueAV.anyseqValue == anyseqValue` will use the `==` proc for seqs, 
which internally will use the generic `==` proc for objects to compare the 
`AnyValue` objects in the seq. Since that proc doesn't support case objects, 
and `AnyValue` is a case object, it fails. The same thing happens with 
`boolValueAV == boolValueAV`, since in that case you are also comparing case 
objects.


Re: Resolve: Error: parallel 'fields' iterator does not work for 'case' objects

2018-03-17 Thread GULPF
This happens because the built in `==` operator for objects simply doesn't work 
for case objects. You can get the same behavior by doing `boolValueAV == 
boolValueAV`. It should be possible to fix it by defining your own `==` 
operator for `AnyValue`.


Re: Resolve: Error: parallel 'fields' iterator does not work for 'case' objects

2018-03-17 Thread monster
In my "full modules", I have something like 22 types supported now. avAnySeq is 
the _last_ one to be checked, and the only one to fail (except for the float 
/float64 case). If I understand your reply properly, it's just "luck" that it 
only fails for avAnySeq? Maybe I shouldn't use "42" everywhere as test value...


Resolve: Error: parallel 'fields' iterator does not work for 'case' objects

2018-03-17 Thread monster
As I said in the previous post, I'm trying to create a "Any Value" case type. 
Another problem I have is supporting "seq[AnyValue]". Seq of anything else 
seems to work. Maybe it's a type recursion problem? Is there a work-around?

Here's the example:


type
  AnyValueType* = enum
avBool,
# ...
avBoolSeq,
# ...
avAnySeq
  
  AnyValue* = object
case kind*: AnyValueType
of avBool: boolValue*: bool
# ...
of avBoolSeq: boolSeqValue*: seq[bool]
# ...
of avAnySeq: anyseqValue*: seq[AnyValue]

converter toBoolAnyValue*(v: bool): AnyValue {.inline, noSideEffect.} =
  result.kind = avBool
  result.boolValue = v

converter toBoolSeqAnyValue*(v: seq[bool]): AnyValue {.inline, 
noSideEffect.} =
  result.kind = avBoolSeq
  result.boolSeqValue = v

converter toSeqAnyValueAnyValue*(v: seq[AnyValue]): AnyValue {.inline, 
noSideEffect.} =
  result.kind = avAnySeq
  result.anyseqValue = v

when isMainModule:
  let boolValue: bool = true
  let boolValueAV: AnyValue = boolValue
  let boolSeqValue: seq[bool] = @[boolValue]
  let boolSeqValueAV: AnyValue = boolSeqValue
  let anyseqValue: seq[AnyValue] = @[boolValueAV]
  let anyseqValueAV: AnyValue = anyseqValue
  
  assert(boolValueAV.boolValue == boolValue)
  assert(boolSeqValueAV.boolSeqValue == boolSeqValue)
  assert(anyseqValueAV.anyseqValue == anyseqValue) # Compiler bug :(