h3rald / min

A small but practical concatenative programming language and shell
https://min-lang.org
MIT License
309 stars 23 forks source link

Dynamic library attempt fails #13

Closed mwgkgk closed 3 years ago

mwgkgk commented 6 years ago

Creating an example dyntest library, importing it and calling the dynplus function works.

Now, trying to create my own thing, that looks like this:

import mindyn

proc dyntools*(i: In) {.dynlib, exportc.} =

  let def = i.define()

  def.symbol("get-pos") do (i: In):
    var res = newSeq[MinValue](0)
    res.add @["line".newVal, i.currSym.line.newVal].newVal(i.scope)
    res.add @["column".newVal, i.currSym.column.newVal].newVal(i.scope)
    i.push res.newVal(i.scope)

  def.finalize("dyntools")

Fails upon calling get-pos with SIGSEGV: Illegal storage access. (Attempt to read from nil?)

This exact function works when defined in lib/min_lang.nim. Probably using something that's not implemented in mindyn? Or it can be my nonexistent Nim skills. Please point me in the right direction! :) Thank you

h3rald commented 6 years ago

I was able to reproduce your problem 😢. There's nothing wrong with your code, furthermore I commented out a few lines and the problem seems to be the newSeq call, everything else works.

It doesn't really make much sense, but I'll investigate.

h3rald commented 3 years ago

Closing as dynamic support has been removed. At least until there's a way to implement it tidily in a cross-platform way.