fubark / cyber

Fast and concurrent scripting.
https://cyberscript.dev
MIT License
1.19k stars 40 forks source link

"TODO" error when defining out-of-body $call for type trait #95

Closed rdb closed 1 month ago

rdb commented 1 month ago

Hi, thank you for creating this language! It looks interesting. I've been looking into it today and investigating ways it might be possible for me to create Cyber bindings for an object-oriented C++ library.

In the process I came across this oddity. The first thing that I remarked is that it's legal to define out-of-body functions for traits. When using this feature with the $call operator, I encountered a "TODO" error message:

type A trait:
    -- Dummy function to avoid parse error with empty type
    func dummyfunc(self) float

type B:
    with A

    func dummyfunc(self) float:
        return 0

-- Works
func A.test() float:
    return 1

print(A.test())

-- Works
func B.$call() float:
    return 2

print(B())

-- Fails
func A.$call() float:
    return 2

print(A())
CompileError: error.TODO

eval:27:7:
print(A())
      ^

Is this intended to work, or are out-of-body functions under traits not supposed to work to begin with?

fubark commented 1 month ago

Thanks for reporting this. Yea the namespace call is supposed to work on all types including traits. This should be fixed on master.

rdb commented 1 month ago

It works! Thank you!