On Sat, 29 Apr 2017 08:14:38 -0700, sml...@gmail.com wrote: > Returning a Str from a custom class's .gist works fine: > > ➜ class A { method gist { "42" } }; say A.new; > 42 > > But when returning other values, it fails to convert them to Str > automatically, and instead prints an internal-ish error message: > > ➜ class A { method gist { now } }; say A.new; > This type cannot unbox to a native string: P6opaque, Instant > in block <unit> at -e line 1 > > ➜ class A { method gist { 42 } }; say A.new; > This type cannot unbox to a native string: P6opaque, Int > in block <unit> at -e line 1
Feels like a DIHWIDT to me. If you want to override these special methods in your class, it's your job to ensure they return the correct expected type. The error isn't terrible and is correct and improving it would likely require pessimising one of the most oft-used routines.