aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorV1K1NGbg <victor@ilchev.com>2024-08-04 16:22:11 +0300
committerV1K1NGbg <victor@ilchev.com>2024-08-05 20:51:31 +0300
commitd1dc2b9f15eaae12610deee26c8eb8fd91d998fa (patch)
tree359c33cd2ced63c849944957fa2d236789de11af /src
parentb4414cca6e6293f0be627f288d06eab58b8fd913 (diff)
downloadluarocks-d1dc2b9f15eaae12610deee26c8eb8fd91d998fa.tar.gz
luarocks-d1dc2b9f15eaae12610deee26c8eb8fd91d998fa.tar.bz2
luarocks-d1dc2b9f15eaae12610deee26c8eb8fd91d998fa.zip
type_check
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/type/rockspec.tl13
-rw-r--r--src/luarocks/type_check.lua12
-rw-r--r--src/luarocks/type_check.tl14
3 files changed, 26 insertions, 13 deletions
diff --git a/src/luarocks/type/rockspec.tl b/src/luarocks/type/rockspec.tl
index 26f29587..fab87fd4 100644
--- a/src/luarocks/type/rockspec.tl
+++ b/src/luarocks/type/rockspec.tl
@@ -10,6 +10,19 @@ local util = require("luarocks.core.util") --!
10 10
11type_rockspec.rockspec_format = "3.0" 11type_rockspec.rockspec_format = "3.0"
12 12
13-- Syntax for type-checking tables:
14--
15-- A type-checking table describes typing data for a value.
16-- Any key starting with an underscore has a special meaning:
17-- _type (string) is the Lua type of the value. Default is "table".
18-- _mandatory (boolean) indicates if the value is a mandatory key in its container table. Default is false.
19-- For "string" types only:
20-- _pattern (string) is the string-matching pattern, valid for string types only. Default is ".*".
21-- For "table" types only:
22-- _any (table) is the type-checking table for unspecified keys, recursively checked.
23-- _more (boolean) indicates that the table accepts unspecified keys and does not type-check them.
24-- Any other string keys that don't start with an underscore represent known keys and are type-checking tables, recursively checked.
25
13local rockspec_formats, versions = type_check.declare_schemas({ 26local rockspec_formats, versions = type_check.declare_schemas({
14 ["1.0"] = { 27 ["1.0"] = {
15 fields = { 28 fields = {
diff --git a/src/luarocks/type_check.lua b/src/luarocks/type_check.lua
index 77f9ef24..50eceddf 100644
--- a/src/luarocks/type_check.lua
+++ b/src/luarocks/type_check.lua
@@ -31,9 +31,9 @@ type_check.MAGIC_PLATFORMS = {}
31do 31do
32 local function fill_in_version(tbl, version) 32 local function fill_in_version(tbl, version)
33 33
34 if not tbl.fields then 34
35 return 35
36 end 36
37 37
38 for _, v in pairs(tbl.fields) do 38 for _, v in pairs(tbl.fields) do
39 if type(v) == "table" then 39 if type(v) == "table" then
@@ -191,10 +191,10 @@ function type_check.type_check_table(version, tbl, typetbl, context)
191 return nil, errcheck 191 return nil, errcheck
192 end 192 end
193 193
194 if not typetbl.fields then
195 194
196 return true 195
197 end 196
197
198 198
199 for k, v in pairs(tbl) do 199 for k, v in pairs(tbl) do
200 local t = typetbl.fields[tostring(k)] or typetbl._any 200 local t = typetbl.fields[tostring(k)] or typetbl._any
diff --git a/src/luarocks/type_check.tl b/src/luarocks/type_check.tl
index 7c3c4064..6b5dbb16 100644
--- a/src/luarocks/type_check.tl
+++ b/src/luarocks/type_check.tl
@@ -31,9 +31,9 @@ type_check.MAGIC_PLATFORMS = {}
31do 31do
32 local function fill_in_version(tbl: TableSchema, version?: string) 32 local function fill_in_version(tbl: TableSchema, version?: string)
33 33
34 if not tbl.fields then --! validation 34 -- if not tbl.fields then --! validation
35 return 35 -- return
36 end 36 -- end
37 37
38 for _, v in pairs(tbl.fields) do 38 for _, v in pairs(tbl.fields) do
39 if v is TableSchema then 39 if v is TableSchema then
@@ -191,10 +191,10 @@ function type_check.type_check_table(version: string, tbl: {any: any}, typetbl:
191 return nil, errcheck 191 return nil, errcheck
192 end 192 end
193 193
194 if not typetbl.fields then --! validation 194 -- if not typetbl.fields then --! validation
195 -- if there are no fields, exit the checker 195 -- -- if there are no fields, exit the checker
196 return true 196 -- return true
197 end 197 -- end
198 198
199 for k, v in pairs(tbl) do 199 for k, v in pairs(tbl) do
200 local t = typetbl.fields[tostring(k)] or typetbl._any --! tostring 200 local t = typetbl.fields[tostring(k)] or typetbl._any --! tostring