godot
godot copied to clipboard
3 to 4 converter adds seemingly spurious ") #"
Godot version
v4.0.stable.official [92bee43ad]
System information
Windows 10
Issue description
This Godot 3 line
assert(r.hash() == {"a":1, "b":2}.hash())
was converted to this:
assert(r.hash() == {"a":1) #,"b":2}.hash())
For some reason ) # is added after 1.
Steps to reproduce
Just converting Godot 3 project containing the line to Godot 4.
Minimal reproduction project
N/A
it would seem this part of the converter's code is responsible for this:
https://github.com/godotengine/godot/blob/3695fe5a573678c6491a6a33f19f9329d3256a48/editor/project_converter_3_to_4.cpp#L2022
the whole block looks like this:
// assert(speed < 20, str(randi()%10)) -> assert(speed < 20) #,str(randi()%10)) GDScript - GDScript bug constant message
if (line.contains("assert(")) {
int start = line.find("assert(");
int end = get_end_parenthesis(line.substr(start)) + 1;
if (end > -1) {
Vector<String> parts = parse_arguments(line.substr(start, end));
if (parts.size() == 2) {
line = line.substr(0, start) + "assert(" + parts[0] + ") " + line.substr(end + start) + "#," + parts[1] + ")";
}
}
}