Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when exporting seq[T] #84

Open
arunvickram opened this issue Dec 30, 2020 · 2 comments
Open

Error when exporting seq[T] #84

arunvickram opened this issue Dec 30, 2020 · 2 comments

Comments

@arunvickram
Copy link
Contributor

arunvickram commented Dec 30, 2020

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.

@Xzayler
Copy link

Xzayler commented Jul 11, 2022

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.

@arunvickram
Copy link
Contributor Author

I haven't yet, I just moved on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants