pragmagic/godot-nim

Error when exporting `seq[T]`

arunvickram opened this issue · 2 comments

I'm running into an issue where I have an object subclassing a resource:

import godot
import godotapi/resource
import source/party/skill

type SkillsList = seq[Skill]

gdobj Job of Resource:
  var jobName* {.gdExport.}: string = ""
  var skills* {.gdExport.}: seq[string] = @[ ]

The error I'm getting is:

nim/godotnim.nim(769, 9) Error: type mismatch: got <typeof(nil)> but expected 'seq[string]'

I looked into it and it's referencing this proc:

proc fromVariant*[T](s: var seq[T], val: Variant): ConversionResult =
  if val.getType() == VariantType.Nil:
    s = nil
  elif val.getType() == VariantType.Array:
    let arr = val.asArray()
    var newS = newSeq[T](arr.len)
    for idx, item in arr:
      mixin fromVariant
      let convResult = fromVariant(newS[idx], item)
      if convResult != ConversionResult.OK:
        return convResult
    shallowCopy(s, newS)
  else:
    result = ConversionResult.TypeError

and the line it's through an error on is the s = nil. I'm not sure how gdobj gets to the point where it assumes that val is VariantType.Nil, but that seems to be causing the issue.

Did you manage to fix it? I'm having the same problem exactly.
I know it's a very old issue but I'm lost.

I haven't yet, I just moved on