mojo
mojo copied to clipboard
[Feature Request] Add a `type` builtin
Bug Description
type() is not in mojo
Steps to Reproduce
when print(type)
was run, the expected output is "<class 'type'>" but the actual output is "error: Expression: use of unknown declaration 'type'".
Context
Unfortunately you need to do something like this at this point
let py = Python.import_module("builtins")
py.print(py.type) # <class 'type'>
The issue with adding the type
bultin to Mojo is that we don't have a runtime type representation yet. I.e. in Python, type
returns a type instance that can be used like a class.
As a temporary workaround, maybe it could return a string representation of the type? Being able to debug types more easily would be very handy.