Skip to content

GDScript formatted strings overwritten with old values when passed an empty array. #97176

Closed
@Jack-023

Description

@Jack-023

Tested versions

v4.3.stable.arch_linux

System information

Godot v4.3.stable unknown - Arch Linux #1 SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:21:02 +0000 - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3090 (nvidia; 560.35.03) - AMD Ryzen 7 5800X 8-Core Processor (16 Threads)

Issue description

When a formatted string using the % operator is given an empty array of arguments, it will replace the entire string (not just the placeholder) with the previous formatted string.

print("working %s string" % "formatted")
print("non-formatted string")
print("broken %s string" % [])

Will output

> working formatted string
> non-formatted string
> working formatted string

It does produce an error saying there are not enough arguments for the format string but it still runs and the output it produces is pretty confusing.

Steps to reproduce

See above.

Minimal reproduction project (MRP)

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions