Skip to content

Commit

Permalink
Fix bug in recursive proto generation where julia keywords are present.
Browse files Browse the repository at this point in the history
Also add a test.
  • Loading branch information
dewilson committed Dec 16, 2021
1 parent bae7008 commit 8340930
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/gen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ end

function generate_msgtype(outio::IO, errio::IO, dtype::DescriptorProto, scope::Scope, syntax::String, exports::Vector{String}, depends::Vector{String}, mapentries::Dict{String,Tuple{String,String}}, deferedmode::Bool)
full_dtypename = fullname(scope, dtype.name)
deferedmode && !isdeferred(full_dtypename) && return

io = IOBuffer()
modul,dtypename = splitmodule_chkkeyword(full_dtypename)
full_dtypename = (modul=="") ? dtypename : "$(modul).$(dtypename)"
deferedmode && !isdeferred(full_dtypename) && return
@debug("begin type $(full_dtypename)")
add_name_map(dtype.name, full_dtypename)

Expand Down
18 changes: 18 additions & 0 deletions test/proto/recursive_julia_keyword.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
syntax = "proto2";

package TypeRecurse;

message RecurseA {
required string a = 1;
optional Type b = 2;
}

message Type {
required string b = 1;
optional RecurseC c = 2;
}

message RecurseC {
required string c = 1;
optional Type next = 2;
}
5 changes: 5 additions & 0 deletions test/testprotoc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const PROTOC_TESTCASES = [
check="include(\"recursive_pb.jl\")",
envs=[],
),
(
files=["recursive_julia_keyword.proto"],
check="include(\"recursive_julia_keyword_pb.jl\")",
envs=[],
),
(
files=["a.proto", "b.proto"],
check="include(\"AB.jl\"); using .AB; using .AB.A, .AB.B",
Expand Down

0 comments on commit 8340930

Please sign in to comment.