Does not have witness table for trait

Earlier the following(or something similar) used to work. I updated to latest mojo and it has started giving me the error listed underneath the code snippet! How can I make this work?

mojo --version => Mojo 25.5.0.dev2025071818 (0b26378c)
@fieldwise_init
struct T(Copyable & Movable):
    alias InnerFn = fn (input: String) escaping -> String
    var inner_fn: UnsafePointer[Self.InnerFn]

    fn __init__(out self):
        self.inner_fn = UnsafePointer[Self.InnerFn]()

    fn do_it(self) -> Self:
        fn some_inner_fn(input: String) escaping -> String:
            return input.upper()

        result = T()
        result.inner_fn = UnsafePointer[Self.InnerFn].alloc(1)
        result.inner_fn.init_pointee_copy(some_inner_fn)
        return result


fn main() raises:
    t = T()
    result = t.do_it()
    from_inner = result.inner_fn[]("here goes my input")

Error:

call expansion failed
        result.inner_fn.init_pointee_copy(some_inner_fn)
        
memory/unsafe_pointer.mojo:1108:56: note: instantiated struct type @"testbed::fn(input: String) escaping -> String" does not have witness table for trait stdlib::builtin::value::Copyable

The exact same code works in:

mojo Mojo 25.5.0.dev2025061605 (65500ff8)

Here is the output - HERE GOES MY INPUT

And with mojo Mojo 25.5.0.dev2025071818 (0b26378c) 

unsafe_pointer.mojo:1108:56: note: instantiated struct type @"witness::fn(input: String) escaping -> String" does not have witness table for trait stdlib::builtin::value::Copyable

Hi @ratulb, thanks for reporting! Please file an issue on github so we can track this. Thank you!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.