Skip to content

string length type inconsistency #1338

@asmaloney

Description

@asmaloney

Godot version

4.2

godot-cpp version

4.2-stable

System information

macOS (but it's irrelevant)

Issue description

In the test code:

String Example::test_string_resize(String p_string) const {
	int orig_len = p_string.length();
	p_string.resize(orig_len + 3);
...

String::length() returns an int64_t, but String::resize() only takes an int:

Error resize(int p_size);

When dealing with string sizes, the type should be consistent throughout the class. In fact I would recommend creating a type for it so it's obvious when we're dealing with lengths. Something like:

using StringLen = int64_t;

StringLen length() const;
Error resize(StringLen p_size);

Steps to reproduce

(It's an API bug.)

Minimal reproduction project

(It's in the test code: test/src/example.cpp - Example::test_string_resize)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions