Op error reporting confusing

Hi.
I have n Op ‘custom_add’ defined that produces result a custom type, let us say T1. When an instance of that Op is supplied a different type , say T2, then instead of the the error saying something like ’ Op custom_add expects result type T1, supplied type is of type T2’, it says, ‘dialect has no registered type printing hook’. What am I missing here? I don’t want custom printing of my op, i just want the error to end-user to indicate clearly that they supplied wrong type. However, if T2 is a builtin type then i get the good message "op result #0 must be T1 type, but got ‘tensor<3xui1>’ . How should I fix this?
Thanks a lot.

Hey,

Could you verify that the dialect of the unsupported type has been loaded? The error seems to suggest that it did try to print out the type and failed to find the dialect loaded of the type being passed to it [this may also be a case where in errors we should just print out the generic representation of the type or some such, so if you have a minimal case that would be good to look at]

Yeah to be able to print "op result #0 must be T1 type, but got T2 we need a printer for T2. The error you get is that the dialect for T2 does not have a printer.

Thanks. I see why I need a printer now (to report the custom-type).
I do the parsing through the function ‘mlir::Type MyDialect::parseType(mlir::DialectAsmParser &parser) const {… }’. Is there something similar I can do for printer ? Any pointers would help as I have not done printers in mlir before
Thanks

This section of the tutorial may be helpful: Chapter 7: Adding a Composite Type to Toy - MLIR

Thanks. That works. Got it working. I thought incorrectly that I should do something in tableGen for it.