oniksan/godobuf

Field names can conflict with builtin names

rcorre opened this issue · 2 comments

rcorre commented

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?

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

rcorre commented

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