Skip to content

Commit a1bbee5

Browse files
committed
Treat numbers as literal Doc values
1 parent 12aab48 commit a1bbee5

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

src/Foreign/Lua/Module/DocLayout.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ docTypeName = "HsLua DocLayout.Doc"
237237
peekDoc :: StackIndex -> Lua (Doc Text)
238238
peekDoc idx = Lua.ltype idx >>= \case
239239
Lua.TypeString -> Doc.literal <$> Lua.peek idx
240+
Lua.TypeNumber -> Doc.literal <$> Lua.peek idx
240241
_ -> Lua.reportValueOnFailure docTypeName
241242
(`Lua.toAnyWithName` docTypeName)
242243
idx

test/test-doclayout.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ return {
3838
assert.are_equal(doclayout.render('hello world'), 'hello world')
3939
end),
4040

41+
test('numbers can be used as Doc values', function ()
42+
assert.are_equal(doclayout.render(42), '42')
43+
end),
44+
4145
test('equality', function ()
4246
assert.is_truthy(doclayout.literal "true", doclayout.literal "true")
4347
end),

0 commit comments

Comments
 (0)