Use early return when type checking function calls
This is a purely stylistic change.
@@ -794,7 +794,12 @@ function Checker:check_exp_synthesize(exp)
exp.exp = self:check_exp_synthesize(exp.exp)
local f_type = exp.exp._type
- if f_type._tag == "types.T.Function" then
+ if f_type._tag ~= "types.T.Function" then
+ type_error(exp.loc,
+ "attempting to call a %s value",
+ types.tostring(exp.exp._type))
+ end
+
self:expand_function_returns(f_type.arg_types, exp.args)
if #f_type.arg_types ~= #exp.args then
@@ -817,12 +822,6 @@ function Checker:check_exp_synthesize(exp)
end
exp._types = f_type.ret_types
- else
- type_error(exp.loc,
- "attempting to call a %s value",
- types.tostring(exp.exp._type))
- end
-
elseif tag == "ast.Exp.CallMethod" then
error("not implemented")
