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

Variant Parameter and Return Type Shows Up as (no base) #159

Closed
Dheatly23 opened this issue Mar 8, 2023 · 9 comments · Fixed by #229
Closed

Variant Parameter and Return Type Shows Up as (no base) #159

Dheatly23 opened this issue Mar 8, 2023 · 9 comments · Fixed by #229
Labels
bug c: register Register classes, functions and other symbols to GDScript

Comments

@Dheatly23
Copy link
Contributor

I have method with complex multiple dispatch of arguments and maybe empty return value. Since Option<T> is not supported as parameters nor return value, i use Variant as workaround.

Example:

#[func]
fn method(&self, arg0: Variant) -> Variant {
    // ...
}

But when i call it in GDScript, it errors with:

Line [XXX]: Cannot get return value of call to "method()" because it returns "void".

When i checked into it's documentation i saw this in methods section:

(no base) method(arg0: (no base))

Is this normal? I can't call it since it returns "void" even though it's not.

@lilizoey
Copy link
Member

lilizoey commented Mar 8, 2023

does the class you're defining method on have a base field? could you show the class struct either way?

@Dheatly23
Copy link
Contributor Author

Yes the class have base field. I can't exactly whip up a minimal example right now, but it's in (interim) port of my addon.

@Bromeon
Copy link
Member

Bromeon commented Mar 8, 2023

I wonder if this has been introduced with #147.

@Dheatly23 could you check if this also occurs with a revision before that was merged?

[dependencies]
godot = { git = "https://github.com/godot-rust/gdextension", rev = "7d42ebb425ada12459ca810e39f4277d6ddefd32" }

@Bromeon Bromeon added bug c: register Register classes, functions and other symbols to GDScript labels Mar 8, 2023
@Dheatly23
Copy link
Contributor Author

Dheatly23 commented Mar 8, 2023

Nope, still shows up as (no base)

image

For example, the call_wasm method has this signature:

#[func]
fn call_wasm(&self, name: StringName, args: Array) -> Variant {
    // ...
}

@primoze
Copy link

primoze commented Mar 8, 2023

This issue has been present since at least #133 with godot rc5, that's where I first encountered it.

@the-ssd
Copy link

the-ssd commented Mar 9, 2023

in docs everything shows up as (no base) but when you start wring function and helper shows up with correct types and names

example:
image
in the example I don't use Object because #[godot_api] errors and not callable because it is working

@the-ssd
Copy link

the-ssd commented Mar 9, 2023

I just checked godot-cpp
docs in test project work and with Variant

@Dheatly23
Copy link
Contributor Author

Yeah, i guess some part of it is in Godot docs system itself:
image

The biggest problem is return value is void, so i can't get the return value. If only i can turn off type checking 🤷‍♂️

@the-ssd
Copy link

the-ssd commented Mar 10, 2023

I think you can return bool and ints
maybe as temporary solution convert to bytes and then back

like this:
image
and use var_to_bytes_with_objects() to convert to bytes
use godot::prelude::utilities::var_to_bytes_with_objects;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug c: register Register classes, functions and other symbols to GDScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants