Skip to content

insert dynamic type checking code #109

@tmbdev

Description

@tmbdev

I'd like to use typedlua to compile code for use in regular, dynamically typed Lua applications. That is, most of the code that will be using my code as a library is likely going to be not statically typed.

For that, I'd find it useful if there was an option to have typedlua insert type checking code at the boundary between dynamic Lua code and typedlua code.

Concretely, I'd find it useful if "typedlua -t example.lua" would transform something like this:

function f(x: string): string
    return x..x
end

into

f = function (x) 
  if type(x) ~= "string" then error("function f, argument x:string, got "..type(x)) end
  return x .. x
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions