Skip to content

Commit 85e18a2

Browse files
committed
Add more aggressive workaround for Penlight №307
1 parent 208ee6e commit 85e18a2

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

fluent/resource.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,14 @@ function FluentResource:_init (ast)
4444
flush()
4545
-- Work around Penlight #307
4646
-- self:catch(self.get_message)
47-
self:catch(function(_, identifier) return self:get_message(identifier) end)
4847
return self
4948
end
5049

5150
function FluentResource:load_node (node)
51+
-- Work around Penlight #307
52+
if not type(rawget(getmetatable(self), "__index")) ~= "function" then
53+
self:catch(function(_, identifier) return self:get_message(identifier) end)
54+
end
5255
local body = self.body
5356
local k = #body + 1
5457
body[k] = node

spec/fluent_spec.lua

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,12 @@ foo =
164164
-- assert.same("qux", bundle["bar.bax"]())
165165
-- assert.same("qux", bundle.bar:get_attribute("bax")())
166166
assert.same("baz", bundle.bar())
167-
-- TODO fix property accessor on resource
168-
-- assert.same("baz", en.bar())
167+
assert.same("baz", en.bar())
169168
assert.same("baz", bundle:format("bar"))
170169
assert.same("qux", bundle:get_message("bar"):get_attribute("bax")())
171170
bundle:add_messages("bar = rebar")
172171
assert.same("rebar", bundle.bar())
173-
-- TODO fix property accessor on resource
174-
-- assert.same("rebar", en.bar())
172+
assert.same("rebar", en.bar())
175173
assert.same("rebar", bundle:format("bar"))
176174
assert.error(function() return bundle:get_message("bar"):get_attribute("bax")() end)
177175
-- assert.same("qux", bundle.bar.bax())
@@ -239,6 +237,9 @@ foo =
239237
local tr = bundle:get_resource("tr")
240238
assert.same("merhaba", tr:format("hi"))
241239
assert.same("hello", en:format("hi"))
240+
-- TODO Penlight hack doesn't work around this?
241+
-- assert.same("merhaba", tr.hi())
242+
-- assert.same("hello", en.hi())
242243
end)
243244

244245
end)

0 commit comments

Comments
 (0)