godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.39k stars 21.26k forks source link

Godot4.4-dev5: Breaks my mock implementation, `get_method_list` provides invalid method info for `get_primary_rotation_axis` #99531

Closed MikeSchulze closed 3 days ago

MikeSchulze commented 3 days ago

Tested versions

v4.4.dev5.mono.official [9e6098432]

System information

All

Issue description

I'm providing a mocking util for testing in my plugin GdUnit4 and the test are broken now. My tests try to mock all Godot classes, and it fails now on LookAtModifier3D#get_primary_rotation_axis The method is documented as Image

But the Vector3 has no enum Axis defined.

Steps to reproduce

Run the script to check the provided method info.

extends Node

func _ready() -> void:
    get_method_info()
    get_tree().quit()

func get_method_info() -> void:
    var modifier := LookAtModifier3D.new()

    var axis := modifier.get_primary_rotation_axis()
    prints("get_primary_rotation_axis value:", axis, "return type:", typeof(axis))

    var methods := modifier.get_method_list()
    var mi_get_primary_rotation_axis := methods.filter(func(m :Dictionary) -> bool:
        return m["name"] == "get_primary_rotation_axis"
    )
    prints(mi_get_primary_rotation_axis[0]["return"])

The output is:

get_primary_rotation_axis value: 1 return type: 2
{ "name": "", "class_name": &"Vector3.Axis", "type": 2, "hint": 0, "hint_string": "", "usage": 65542 }

I use the provided method info to build the mocking class, and it will not be compiling about missing enum Vector3.Axis

e.g. use a valid script code will show the compile error var axis_typed :Vector3.Axis = modifier.get_primary_rotation_axis()

Parse Error: Built-in types don't contain nested types. Same issues for all classes inherits from SpriteBase3D

Minimal reproduction project (MRP)

n/a

akien-mga commented 3 days ago

Related to #98446 which added the method, though it's not the first use of Vector3.Axis in the API, so I'm surprised it's only a problem now for your use case.

99424 sounds related and might solve this? CC @dalexeev

dalexeev commented 3 days ago

e.g. use a valid script code will show the compile error var axis_typed :Vector3.Axis = modifier.get_primary_rotation_axis()

Parse Error: Built-in types don't contain nested types.

#99424 sounds related and might solve this?

Yes, it should fix this, see the test analyzer/features/global_builtin_and_native_enums.gd in the PR.

MikeSchulze commented 3 days ago

@akien-mga it is an older issue right, I checked my mock tests and see I had explicit excluded "Sprite3D", "AnimatedSprite3D" in the past, but I can't remember which version of Godot

Sithoid commented 3 days ago

@akien-mga it is an older issue right, I checked my mock tests and see I had explicit excluded "Sprite3D", "AnimatedSprite3D" in the past, but I can't remember which version of Godot

I'm fairly confident it exists at least in 4.3 stable (and perhaps earlier), since this PR originated as an attempt to fix #99309 (which turned out to be a minor symptom of the same core problem)