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

var_to_bytes omits type of typed array #76841

Closed
Grandro opened this issue May 8, 2023 · 1 comment · Fixed by #78219
Closed

var_to_bytes omits type of typed array #76841

Grandro opened this issue May 8, 2023 · 1 comment · Fixed by #78219
Milestone

Comments

@Grandro
Copy link

Grandro commented May 8, 2023

Godot version

v4.0.2.stable.official [7a0977c]

System information

Windows 11

Issue description

@export var _e_export: Array[String]
func _ready():
    var bytes_export = var_to_bytes(_e_export)
    var var_export = bytes_to_var(bytes_export)
    _e_export = var_export # Error

This snippet of code will crash with the error Trying to assign an array of type "Array" to a variable of type "Array[String]". because var_to_bytes doesn't seem to store the type of the typed array _e_export.

Steps to reproduce

  1. Create a new project
  2. Create a new empty scene and place the code snippet above inside a node

Minimal reproduction project

Typed_Array_Var_To_Bytes.zip

@anvilfolk
Copy link
Contributor

Not sure whether this qualifies as a bug or not - partly because the implementation of typed arrays isn't fully complete yet and no one is currently working on it :)

But as a work-around, the following works:

extends Node
@export var _e_export: Array[String]
func _ready():
	var bytes_export = var_to_bytes(_e_export)
	var var_export = bytes_to_var(bytes_export)
	_e_export.assign(var_export) # No Error
	print(_e_export)

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

Successfully merging a pull request may close this issue.

4 participants