-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
load()
returns GDScript
even with Parse error
, but new()
method can't be called and error is undetectable
#96065
Comments
load()
returns GDScript
even with Parse error
, but new()
method is missing and error is undetectableload()
returns GDScript
even with Parse error
, but new()
method can't be called and error is undetectable
Please test in 4.2.2, or 4.3, 4.2.1 is no longer supported and this might have been fixed. |
Sounds related to: Which was fixed in 4.3 by: |
Reproduced on v4.3.stable.official [77dcf97] |
|
I believe it would be more intuitive if, instead of the current error message stating that the Such an error message would better guide users toward understanding the root cause of the issue and encourage the use of Thank you for your input and the reference to the This response was generated with the assistance of GPT. |
Tested versions
v4.2.1.stable.official [b09f793]
v4.3.stable.official [77dcf97]
System information
Godot v4.2.1.stable
Issue description
When loading a
.gd
script using theload()
function in Godot, the function returns aGDScript
object even if there are parsing errors in the script. This is unexpected because:GDScript
object should always have anew()
method.loaded.has_method("new")
returningtrue
, callingloaded.new()
results in the error:This issue is problematic because there's no clear way to detect or handle this scenario programmatically. Even with parse errors, the script loads and appears valid according to the checks. The only way to detect that the script has issues is by using
loaded.reload()
, which returns a non-zero value if errors are present. However, relying on this method for error detection is not intuitive or well-documented.Expected behavior:
Steps to reproduce
Here’s an example of the code and its output in both normal and error scenarios:
Code:
Output with a valid script:
Output with a script containing parse errors:
Error encountered:
Steps to reproduce:
Minimal reproduction project (MRP)
gdscript load issue project.zip
The text was updated successfully, but these errors were encountered: