Skip to content

Commit 4301c41

Browse files
committed
fix the ignorance of the second load of unnamed schema
1 parent 20f9254 commit 4301c41

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

protoc.lua

+2-3
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,6 @@ local function make_context(self, lex)
737737
end
738738

739739
function Parser:parse(src, name)
740-
name = name or "<input>"
741-
742740
local loaded = self.loaded[name]
743741
if loaded then
744742
if loaded == true then
@@ -747,7 +745,8 @@ function Parser:parse(src, name)
747745
return loaded
748746
end
749747

750-
local lex = Lexer.new(name or "<input>", src)
748+
name = name or "<input>"
749+
local lex = Lexer.new(name, src)
751750
local info = { name = lex.name }
752751
if name then self.loaded[name] = true end
753752
local ctx = make_context(self, lex)

test.lua

+11
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,17 @@ function _G.test_slice()
799799
end
800800

801801
function _G.test_load()
802+
do
803+
local old = pb.state(nil)
804+
protoc.reload()
805+
local p = protoc.new()
806+
assert(p:load [[ message Test1 { optional int32 t = 1; } ]])
807+
assert(pb.type "Test1")
808+
assert(p:load [[ message Test2 { optional int32 t = 2; } ]])
809+
assert(pb.type "Test2")
810+
pb.state(old)
811+
end
812+
802813
local old = pb.state(nil) -- discard previous one and save
803814
assert(old.setdefault)
804815
eq(pb.type ".google.protobuf.FileDescriptorSet", nil)

0 commit comments

Comments
 (0)