Pulse Works Studio
Parse Error: Identifier "File" not declared in the current scope.
The File class is gone. Godot 4 reads and writes bytes through FileAccess.
Cause
Godot 3 constructed a File, then called open(). That type is not in Godot 4, and it is not in the class rename table, so there is no "did you mean" hint. FileAccess.open returns null when the path cannot be opened.
Fix
func read_text(path: String) -> String:
var file := FileAccess.open(path, FileAccess.READ)
if file == null:
push_error(FileAccess.get_open_error())
return ""
var text := file.get_as_text()
file.close()
return text
Related
Godot Dev Tools is a Pulse Works Studio project. All error explainers.