CityOfZion/neo-boa

Built in str is not implemented

Closed this issue · 2 comments

I created a file int2str.py in CLI
these are the contents:

def Main(num):
    result = ''
    result = int2str(num)
    return result

def int2str(num):
    res = ''
    lastdigit = 0
    while num > 9:
        lastdigit = num % 10
        num = num / 10
        res = str(lastdigit) + res
    res = str(num) + res
    return res

but when i build the file using the command: neo> build int2str.py test 02 07 True False 112
I got error:
Could not execute command: [Compilation error] Built in str is not implemented
File "/usr/lib/python3.6/threading.py", line 884, in _bootstrap
self._bootstrap_inner()
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.6/dist-packages/twisted/_threads/_threadworker.py", line 46, in work
task()
File "/usr/local/lib/python3.6/dist-packages/twisted/_threads/_team.py", line 190, in doWork
task()
File "/usr/local/lib/python3.6/dist-packages/twisted/python/threadpool.py", line 250, in inContext
result = inContext.theWork()
File "/usr/local/lib/python3.6/dist-packages/twisted/python/threadpool.py", line 266, in
inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
File "/usr/local/lib/python3.6/dist-packages/twisted/python/context.py", line 122, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/local/lib/python3.6/dist-packages/twisted/python/context.py", line 85, in callWithContext
return func(*args,**kw)
File "/neo-python/neo/bin/prompt.py", line 999, in run
traceback.print_stack()
Traceback (most recent call last):
File "/neo-python/neo/bin/prompt.py", line 948, in run
self.do_build(arguments)
File "/neo-python/neo/bin/prompt.py", line 393, in do_build
BuildAndRun(arguments, self.Wallet)
File "/neo-python/neo/Prompt/Commands/BuildNRun.py", line 46, in BuildAndRun
contract_script = Compiler.instance().load_and_save(path)
File "/usr/local/lib/python3.6/dist-packages/boa/compiler.py", line 97, in load_and_save
data = compiler.write()
File "/usr/local/lib/python3.6/dist-packages/boa/compiler.py", line 73, in write
out_bytes = bytes(self.entry_module.write())
File "/usr/local/lib/python3.6/dist-packages/boa/code/module.py", line 206, in write
self.link_methods()
File "/usr/local/lib/python3.6/dist-packages/boa/code/module.py", line 235, in link_methods
method.prepare()
File "/usr/local/lib/python3.6/dist-packages/boa/code/method.py", line 180, in prepare
exp.tokenize()
File "/usr/local/lib/python3.6/dist-packages/boa/code/expression.py", line 286, in tokenize
token.to_vm(self.tokenizer, last_token)
File "/usr/local/lib/python3.6/dist-packages/boa/code/pytoken.py", line 263, in to_vm
tokenizer.convert_method_call(self)
File "/usr/local/lib/python3.6/dist-packages/boa/code/vmtoken.py", line 464, in convert_method_call
vmtoken = self.convert_built_in(fname, pytoken)
File "/usr/local/lib/python3.6/dist-packages/boa/code/vmtoken.py", line 648, in convert_built_in
"[Compilation error] Built in %s is not implemented" % op)
NotImplementedError: [Compilation error] Built in str is not implemented

Anyone who knows how to fix it? Thanks..

@Razeyer When I ran your program on private net, I get the same errors but it is still able to run the program

Calling Projects/int2str.py with arguments ['1234']
Test deploy invoke successful
Used total of 201 operations
Result [{'type': 'String', 'value': '10'}]
Invoke TX gas cost: 0.0001

Are you still having the issue?

There's no real types in the VM, it is all a bytearray. For this reason, you can't use the str function.