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

PackedByteArray copied and converted to Array without error when passed to a function with typed arguments #89829

Open
clubby789 opened this issue Mar 23, 2024 · 1 comment · May be fixed by #89853

Comments

@clubby789
Copy link
Contributor

clubby789 commented Mar 23, 2024

Tested versions

4.2.1.stable.arch_linux

System information

Godot v4.2.1.stable unknown - Manjaro Linux #1 SMP PREEMPT_DYNAMIC Fri Mar 15 21:05:45 UTC 2024 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4060 (nvidia; 550.67) - Intel(R) Core(TM) i7-9700F CPU @ 3.00GHz (8 Threads)

Issue description

If a function has an Array-typed param, passing a PackedByteArray to it will not cause an error, and will silently convert the PBA to a normal Array (and making it effectively passed by value).

extends Node2D

func _ready():
    var val := PackedByteArray()
    val.resize(10)
    val.fill(0)
    print(val)  	# [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    f1(val) 		# No error!
    print(val)	# [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

func f1(param: Array):
    param[5] = 10
    print(param) 	# [0, 0, 0, 0, 0, 10, 0, 0, 0, 0]

Steps to reproduce

Run the above code - there is no type error and val is not updated in _ready

Minimal reproduction project (MRP)

N/A

@KoBeWi
Copy link
Member

KoBeWi commented Mar 24, 2024

Related #40249

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.

3 participants