Open
Description
Tested versions
- Godot 4.2.1
- Godot 4.0
System information
Microsoft Windows [Version 10.0.22621.3007]
Issue description
Using has_method
on a scene instance can result in a true
result when the .get_script()
's script has the function, however if you then run call()
it will error
Steps to reproduce
manager.gd
@tool
extends Node3D
const Child = preload("res://child.tscn")
@export var pass_btn: bool = false:
set(ticked):
if not ticked: return
pass_btn = false
will_pass()
@export var error_btn: bool = false:
set(ticked):
if not ticked: return
error_btn = false
will_error()
func will_pass():
var ref = Child.instantiate()
var script = ref.get_script()
print(script.has_method("test")) # print: true
script.call("test") # print: Hello From child
script.test() # print: Hello From child
func will_error():
var ref = Child.instantiate()
print(ref.has_method("test")) # print: true
ref.call("test") # error: Invalid call. Nonexistent function 'test (via call)' in base 'Node3D (child.gd)'.
ref.test() # error: Invalid call. Nonexistent function 'test' in base 'Node3D (child.gd)'
child.gd
extends Node3D
static func test():
print("Hello From child")