oniksan / godobuf

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

Field names can conflict with builtin names #34

Closed rcorre closed 9 months ago

rcorre commented 10 months ago

Given the proto:

// Sent from client->server
message Request {
    message Init{}

    oneof kind {
        Init init = 1;
    }
}

Godobuf generates:

class Request:
    func _init():
        var service

        _init = PBField.new("init", PB_DATA_TYPE.MESSAGE, PB_RULE.OPTIONAL, 1, true, DEFAULT_VALUES_3[PB_DATA_TYPE.MESSAGE])
        service = PBServiceField.new()
        service.field = _init
        service.func_ref = Callable(self, "new_init")
        data[_init.tag] = service

    var data = {}

    var _init: PBField

Which fails to compile with Variable "_init" has the same name as a previously declared function.. Maybe generated variable names should use a __ prefix to dodge conflicts?

oniksan commented 10 months ago

Hi! I see you have already fix it, please make a pull request

rcorre commented 10 months ago

Will do! I was just using a bit locally first to make sure I didn't break anything