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

Upgrading project to 4.4 results in GDScript parser errors #102557

Closed
mihe opened this issue Feb 7, 2025 · 0 comments · Fixed by #102636
Closed

Upgrading project to 4.4 results in GDScript parser errors #102557

mihe opened this issue Feb 7, 2025 · 0 comments · Fixed by #102636

Comments

@mihe
Copy link
Contributor

mihe commented Feb 7, 2025

Tested versions

  • Reproducible in: 4.4.beta3

System information

Godot v4.3.stable - Windows 10.0.26100 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4070 Laptop GPU (NVIDIA; 32.0.15.6636) - AMD Ryzen 9 7940HS w/ Radeon 780M Graphics (16 Threads)

Issue description

I can't quite explain this one, but I happened to run into this when reporting #102551.

In short, there's something strange going on with GDScript when upgrading this particular MRP from 4.3 to 4.4, where you'll be met with parser errors after upgrading, that then manifest themselves at runtime as well.

It seems that it has something to do with the stuff that's cached in the .godot folder, as deleting it resolves the errors, regardless if you delete it before or after upgrading. As such, I've included a more comprehensive set of reproduction steps to create the project from scratch, as opposed to providing an MRP.

I tried reducing down the script to something even more minimal, but for whatever reason this particular script seems to force the problem.

Steps to reproduce

  • Create a new project using 4.3-stable
  • Add a 2D main scene, call it main.tscn
  • Add a new GDScript script through the FileSystem dock, call it my_resource.gd
  • Populate my_resource.gd with the following contents:
extends Resource
class_name MyResource
  • Attach a new script to the root of main.tscn, call it main.gd
  • Populate main.gd with the following contents:
extends Node2D

@export var my_resource: MyResource

func _ready() -> void:
	bytes_to_var_with_objects(var_to_bytes_with_objects(my_resource)) as MyResource
  • Run the main scene
  • Note that it runs without errors
  • Close the project
  • Open the project in Godot 4.4-beta3
  • Go through the upgrade process
  • Note errors in Output pane saying:
ERROR: res://main.gd:3 - Parse Error: Could not find type "MyResource" in the current scope.
ERROR: res://main.gd:3 - Parse Error: Cannot use simple "@export" annotation because the type of the initialized value can't be inferred.
ERROR: res://main.gd:6 - Parse Error: Could not find type "MyResource" in the current scope.
ERROR: modules/gdscript/gdscript.cpp:3022 - Failed to load script "res://main.gd" with error "Parse error".
  • Reload the project
  • Note the lack of errors
  • Run the main scene
  • Note debugger break with error saying Parser Error: Could not find type "MyResource" in the current scope.
  • Close the project
  • Delete the .godot folder
  • Open the project again
  • Run the main scene
  • Note how it runs fine

Minimal reproduction project (MRP)

N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Release Blocker
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants