Updated typedecl.declare to include expected and received argument counts in the error message.
Debugging things in the parser is a bit tricky. One thing that might help is editing the error
message in typedecl.lua to say what was the expected number and how many arguments were received.
@@ -68,7 +68,9 @@ function typedecl.declare(module, mod_name, type_name, constructors)
local function cons(...)
local args = table.pack(...)
if args.n ~= #fields then
- error("wrong number of arguments for " .. cons_name)
+ error(string.format(
+ "wrong number of arguments for %s. Expected %d but received %d.",
+ cons_name, #fields, args.n))
end
local node = { _tag = tag }
for i, field in ipairs(fields) do
