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

Resource.duplicate(true) triggers parser error when resource's script has class_name #70570

Closed
khellste opened this issue Dec 25, 2022 · 3 comments

Comments

@khellste
Copy link

Godot version

4.0beta10

System information

Windows 10, Vulkan

Issue description

duplicate always crashes on a custom resource when subresources=true is passed for the first argument, with the error "Condition "path.is_empty()" is true.". This happens whether or not there are subresources.

Based on the error, it looks like a resource_path is expected, but this is an in-memory resource which has never been persisted to disk.

image

Steps to reproduce

  1. Create a simple custom class extending Resource.
  2. Call duplicate(true) on an instance of the custom class.

Minimal reproduction project

ResourceDuplicationBug.zip

@kleonc
Copy link
Member

kleonc commented Dec 26, 2022

Duplicate of #68666, the same cause: #68666 (comment). Closing as it can be tracked in there (I've added #68666 (comment) to directly refer to this report).

And to be clear: it's not crashing, just triggering a parser error when running from the editor.

@kleonc kleonc changed the title Resource.duplicate(true) crashes for custom resource class Resource.duplicate(true) triggers parser error when resource's script has class_name Dec 26, 2022
@kleonc kleonc closed this as not planned Won't fix, can't repro, duplicate, stale Dec 26, 2022
@rcorre
Copy link
Contributor

rcorre commented Dec 30, 2022

In godot3, duplicate(true) on a custom resource does not create a parse error, but rather a runtime error

SCRIPT ERROR: Trying to assign value of type '' to a variable of type 'PlayerInput.gd'.

Is this still the same issue, or should I file a new one?

@kleonc
Copy link
Member

kleonc commented Dec 30, 2022

@rcorre The root cause seems to be the same: the script is being duplicated and thus it's treated as a completely different script / it's not recognized to be the same as the original script ('PlayerInput.gd'). In the error message it seems that the script's path is being printed out and it's empty ('') because the duplicated script is not saved to any file. So the error itself is rather correct. In master this error (still can be reached after ignoring the parser error) seems to be a little improved as it shows the base type when there's no file path, like:

Trying to assign value of type 'Resource' to a variable of type 'PlayerInput.gd'.

So I'd say yes, that's the same issue. Both:

  • the parser error (not present in 3.x)

and:

  • the type mismatch error on assignment you've mentioned

are just symptoms to the same issue (in 3.x/master): the script being duplicated (when it probably shouldn't).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants