Skip to content

Commit bf7dc6a

Browse files
committed
Use raw access again, less false catches
1 parent f08791a commit bf7dc6a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fluent/_nodes.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ FluentNode._name = "FluentNode"
1717

1818
function FluentNode:_init (ast, resource)
1919
if self._name == "MessageReference" or self._name == "TermReference" then
20-
getmetatable(self)._resource = resource
20+
rawset(getmetatable(self), "_resource", resource)
2121
end
2222
for key, value in pairs(ast) do
2323
if type(key) == "string" then
@@ -295,7 +295,7 @@ FTL.MessageReference = class(FluentNode)
295295
FTL.MessageReference._name = "MessageReference"
296296

297297
function FTL.MessageReference:format (parameters)
298-
return getmetatable(self)._resource:get_message(self.id.name):format(parameters)
298+
return rawget(getmetatable(self), "_resource"):get_message(self.id.name):format(parameters)
299299
end
300300

301301
FTL.TermReference = class(FluentNode)
@@ -314,7 +314,7 @@ function FTL.TermReference:__mul (node)
314314
end
315315

316316
function FTL.TermReference:format (parameters)
317-
return getmetatable(self)._resource:get_term(self.id.name):format(parameters)
317+
return rawget(getmetatable(self), "_resource"):get_term(self.id.name):format(parameters)
318318
end
319319

320320
FTL._TermReference = FTL.TermReference

fluent/resource.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ end
8888
function FluentResource:__add (other)
8989
if not self:is_a(other:is_a()) then error("Cannot merge unlike types") end
9090
for _, node in ipairs(other.body) do
91-
if node._resource then node._resource = self end
91+
if rawget(node, "_resource") then rawset(node, "_resource", self) end
9292
self:load_node(node)
9393
end
9494
return self

0 commit comments

Comments
 (0)