oniksan / godobuf

A Google Protobuf implementation for Godot / GDScript
BSD 3-Clause "New" or "Revised" License
261 stars 36 forks source link

bug: clearing repeated fields breaks them #21

Closed conradhappeliv closed 2 years ago

conradhappeliv commented 2 years ago

I have a repeated proto3 field:

repeated int32 players_in_game = 11;

Adding to the field (msg.add_players_in_game(1)) works fine at first.

However, once you clear the field (msg.clear_players_in_game()), further additions don't work since the field seems to be getting reset to a singular int (I think). Per the language guide, the default value of an cleared repeated field should be an empty array.

Error message:

Invalid call. Nonexistent function 'append' in base 'int'.

For reference, the generated code:

func clear_players_in_game() -> void:
        data[11].state = PB_SERVICE_STATE.UNFILLED
        _players_in_game.value = DEFAULT_VALUES_3[PB_DATA_TYPE.INT32]
func add_players_in_game(value : int) -> void:
        _players_in_game.value.append(value)  # <-- breakage happens here

This is happening on version 0.4.4 on Godot 3.4.

oniksan commented 2 years ago

Hi, conradhappeliv. I read it, I will definitely check, but so far there is not enough time at all, perhaps it will not be very fast.

oniksan commented 2 years ago

Bug fixed in v 0.5.0