diff options
author | Case Duckworth | 2024-04-11 23:02:27 -0500 |
---|---|---|
committer | Case Duckworth | 2024-04-11 23:02:27 -0500 |
commit | 71fb7a4ea8524928f9ed3cec6983a9f2be38d3c6 (patch) | |
tree | 2100445c0028ff476692a9ea40e4b6bb4aa06398 | |
parent | Add -> functions to core (diff) | |
download | lam-71fb7a4ea8524928f9ed3cec6983a9f2be38d3c6.tar.gz lam-71fb7a4ea8524928f9ed3cec6983a9f2be38d3c6.zip |
Add listp to assert_type
-rw-r--r-- | type.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/type.lua b/type.lua index cf24d0c..6dbf313 100644 --- a/type.lua +++ b/type.lua | |||
@@ -266,7 +266,9 @@ end | |||
266 | 266 | ||
267 | -- type assertion | 267 | -- type assertion |
268 | function m.assert_type (x, t) | 268 | function m.assert_type (x, t) |
269 | if not m.isp(x, t) then | 269 | local pred = function (a) return m.isp(a, t) end |
270 | if t == "list" then pred = m.listp end | ||
271 | if not pred(x) then | ||
270 | error("wrong type", m.lamtype(x), t) | 272 | error("wrong type", m.lamtype(x), t) |
271 | end | 273 | end |
272 | end | 274 | end |