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

Constructors for Exported Types? #211

Open
raviteja-bhupatiraju opened this issue Jun 9, 2021 · 2 comments
Open

Constructors for Exported Types? #211

raviteja-bhupatiraju opened this issue Jun 9, 2021 · 2 comments

Comments

@raviteja-bhupatiraju
Copy link

raviteja-bhupatiraju commented Jun 9, 2021

For the type

type TestType = ref object of PyNimObjectExperimental
  name: string
  age: int

in pylib.nim

I can neither do

tt = pylib.TestType("John Doe", 100)

nor

proc new_TestType(n: string, a: int): TestType {.exportpy.} =
  return TestType(name: n, age: a)

This is a much awaited feature for me and I understand this might still be incompletely implemented at this point.
Are getters and setters the only way to construct objects? Or am I doing something wrong? I get no compile errors.

new_TestType throws
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
at runtime from Python.

@yglukhov
Copy link
Owner

Constructors are not supported yet, however new_TestType crash is a bug. Dont know how to fix it yet.

@yglukhov
Copy link
Owner

The crash is fixed. Leaving this open until custom constructors are implemented.

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