godotengine / godotengine/godot-docs
False or misleading var_to_bytes() note about encoding Callable
- Dominant language
- reStructuredText
- Stars
- 5.7k
- Forks
- 3.8k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 25
Description
**Your Godot version:**
4.7.stable
**Issue description:**
The second note says that: "Encoding Callable is not supported and will result in an _**empty value**_, regardless of the data." The empty value is technically not empty, because when I've made a simple check in the editor:
```gdscript
func testfunc():
pass
func _ready():
var bytes = var_to_bytes(testfunc)
print(bytes)
```
It prints `[25, 0, 0, 0]`. So it's not an empty array, but array with some data. But Callable is not valid after deserialization:
```gdscript
var restored = bytes_to_var(bytes)
print("Restored value: ", restored)
print("Is Callable: ", restored is Callable)
if restored is Callable:
print("Is that Callable valid: ", restored.is_valid())
```
It prints the following:
```
Restored value: null::null
Is Callable: true
Is that Callable valid: false
```
I think the documentation would be more accurate if it says that it returns an invalid or empty Callable, rather than suggest that the byte representation is empty.
**URL to the documentation page:**
https://docs.godotengine.org/en/4.7/classes/class_@globalscope.html#class-globalscope-method-var-to-bytes
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the var_to_bytes() documentation page linked in the issue and locate the second note about encoding Callable. Compare its wording with the reported var_to_bytes() and bytes_to_var() output, then revise the note to describe the resulting invalid Callable accurately. Confirm the rendered documentation no longer implies that the byte representation is empty.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100