Help with mlir::value when converting between dialects

Hi,

I have the following pieces of code:

    auto val = rewriter.create<ConstantIntOp>(op->getLoc(), 1, 32);

    auto fooOp = rewriter.create<Foo_CreateOp>(
        op->getLoc(), op->getContext(), val);
    rewriter.replaceOp(op, {fooOp.getODSResults(0)});

The above code gives me an error as such:

error: unexpected error: failed to legalize operation 'Baz' that was explicitly marked illegal

and

    auto fooOp = rewriter.create<Foo_CreateOp>(
        op->getLoc(), op->getContext(), "foo");
    rewriter.replaceOp(op, {fooOp.getODSResults(0)});

This one doesn’t give an error.

I think the constantOp is playing a role here. any ideas?

It is really impossible to tell unless you provide more information. In which pattern is this happening, how is the conversion infra called, what is the input, what other patterns are available. All these things matter.

Closing this as this was related to having not legalized another involved dialect.