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

Inner class in GDScript can no longer refer to its own name #80508

Closed
vmedea opened this issue Aug 11, 2023 · 0 comments · Fixed by #80510
Closed

Inner class in GDScript can no longer refer to its own name #80508

vmedea opened this issue Aug 11, 2023 · 0 comments · Fixed by #80510

Comments

@vmedea
Copy link
Contributor

vmedea commented Aug 11, 2023

Godot version

4.2.dev commit 013e8e3

System information

Any

Issue description

The following code from dialogic no longer works in 4.2-dev, but does in 4.1 and before:

class VariableFolder:
        var data = {}
        var path = ""
        var outside
        func _init(_data, _path, _outside):
                data = _data
                path = _path
                outside = _outside
        
        func _get(property):
                property = str(property)
                if property in data:
                        if typeof(data[property]) == TYPE_DICTIONARY:
                                return VariableFolder.new(data[property], path+"."+property, outside)  ### <====== ERROR ###
                        else:
                                return DialogicUtil.logical_convert(data[property])
        
        func _set(property, value):
                property = str(property)
                if not value is VariableFolder:
                        outside._set_value_in_dictionary(path+"."+property, outside.dialogic.current_state_info['variables'], value)
                        return true
                elif VariableFolder:
                        return true

On compilation this will give the error

SCRIPT ERROR: Compile Error: Identifier not found: VariableFolder
          at: GDScript::reload (res://addons/dialogic/Modules/Variable/subsystem_variables.gd:182)

(line 182 is the VariableFolder.new line)

i bisected it to the following commit, from #79880:

d53fc92b4c6b5e4484e8f0bfff6ac55163dde3fb is the first bad commit
commit d53fc92b4c6b5e4484e8f0bfff6ac55163dde3fb
Author: Danil Alexeev <danil@alexeev.xyz>
Date:   Tue Jul 25 14:21:49 2023 +0300

    GDScript: Fix bug with identifier shadowed below in current scope

Steps to reproduce

i think the issue description is complete enough to allow reproduction, let me know if there's any problems.

Minimal reproduction project

N/A

@akien-mga akien-mga added this to the 4.2 milestone Aug 11, 2023
@dalexeev dalexeev changed the title Local class in GDscript can no longer refer to its own name Inner class in GDScript can no longer refer to its own name Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants