From 418c86e23bd0551a7e3840f58a1c92a449b31a28 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 21 Jan 2023 21:01:42 +0100 Subject: [PATCH 1/4] fix(utils): `do_or_fail` `res` need to be promoted --- src/awesomewm.d.tl/utils.tl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/awesomewm.d.tl/utils.tl b/src/awesomewm.d.tl/utils.tl index a0453a5..828070e 100644 --- a/src/awesomewm.d.tl/utils.tl +++ b/src/awesomewm.d.tl/utils.tl @@ -58,12 +58,12 @@ function utils.do_or_fail(func: function(...: any): (T | nil, string), ... local ok, res, err = pcall(func, ...) - if not (ok and res) then + if not ok then log:error(logger.message_with_metadata("do_or_fail failed!", { error = err })) error(err) end - return res + return res as T -- promote to T since pcall succeeded at this point end return utils -- 2.40.1 From 34e6a65ebce4db0586bdb7a7ca8af3fc322b9b91 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 21 Jan 2023 21:02:35 +0100 Subject: [PATCH 2/4] fix(entity): can't infer record with record --- src/awesomewm.d.tl/entity/Variable_Info.tl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/awesomewm.d.tl/entity/Variable_Info.tl b/src/awesomewm.d.tl/entity/Variable_Info.tl index 03f169e..c0c5fea 100644 --- a/src/awesomewm.d.tl/entity/Variable_Info.tl +++ b/src/awesomewm.d.tl/entity/Variable_Info.tl @@ -16,11 +16,9 @@ end local __Variable_Info: metatable = { __call = function(_self: Variable_Info, name: string | nil, types: List | nil): Variable_Info - name = name or "" - types = types or List() return { - name = name, - types = types, + name = name or "", + types = types or List(), fixup = function(self: Variable_Info) for t in self.types:iter() do -- 2.40.1 From 88229701079115fd0c91a6591a7f6c6764125d29 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 21 Jan 2023 21:03:28 +0100 Subject: [PATCH 3/4] fix(generator): can't infer generic type --- src/awesomewm.d.tl/generator/snippets.tl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/awesomewm.d.tl/generator/snippets.tl b/src/awesomewm.d.tl/generator/snippets.tl index 7d3209b..5060836 100644 --- a/src/awesomewm.d.tl/generator/snippets.tl +++ b/src/awesomewm.d.tl/generator/snippets.tl @@ -30,7 +30,7 @@ end function snippets.render_requires(requires: Map): string local tmpl = [[local $(name) = require "$(path)"]] - local require_statements = List() + local require_statements : List = List() for name, path in requires:iter() do local tmpl_args = { name = name, -- 2.40.1 From 0aaa8e3d8acd1bc855c49e8257feb4df9f0a6731 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 21 Jan 2023 21:04:15 +0100 Subject: [PATCH 4/4] fix(entity): shouldn't redefine signature --- src/awesomewm.d.tl/entity/Function_Info.tl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/awesomewm.d.tl/entity/Function_Info.tl b/src/awesomewm.d.tl/entity/Function_Info.tl index d3e3478..534da92 100644 --- a/src/awesomewm.d.tl/entity/Function_Info.tl +++ b/src/awesomewm.d.tl/entity/Function_Info.tl @@ -18,7 +18,7 @@ local record Function_Info parameters: List return_types: List - append_parameter: function(self: Function_Info, name: string, type: string) + append_parameter: function(self: Function_Info, name: string, types: List) append_return_type: function(self: Function_Info, return_type: string) fixup: function(Function_Info) -- 2.40.1