beef331 / nimscripter

Quick and easy Nim <-> Nimscript interop
MIT License
145 stars 8 forks source link

Using procs from std/os causes error #11

Closed TheSimpleZ closed 2 years ago

TheSimpleZ commented 2 years ago

Hello!

In the following example:

import nimscripter
import nimscripter/vmops

const script = """
import std/os ## <-- this import
proc build*(): bool =
  echo "building nim... "
  echo getCurrentDir().lastPathPart ## <--- and this usage of 'lastPathPart'
  echo "done"
  true

when isMainModule:
  discard build()
"""
addVmops(buildpackModule)
addCallable(buildpackModule):
  proc build(): bool
const addins = implNimscriptModule(buildpackModule)
discard loadScript(NimScriptFile(script), addins)

Causes

....
Hint: ~/Documents/nimscripter/bin/tvmops  [Exec]
Script Error: ~/.choosenim/toolchains/nim-1.6.2/lib/pure/os.nim:812:16 undeclared identifier: 'cmpic'
candidates (edit distance, scope distance); see '--spellSuggest': 
 (2, 5): 'cmp' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system.nim(2245, 8)]
 (2, 5): 'cmp' [proc declared in ~/.choosenim/toolchains/nim-1.6.2/lib/system.nim(943, 6)].

Any tips on how to fix this?

Could maybe be related to https://github.com/nim-lang/Nim/issues/17051

beef331 commented 2 years ago

I think i might need a define flag passed for this to work, so I guess yet another optional parameter to loadScript might be in order.

beef331 commented 2 years ago

Sorry for the delay, forgot about the issue.