[perl #131238] [LTA] "This type cannot unbox to a native string" when not returning a `Str` from method `gist`
Fair enough.
[perl #131238] [LTA] "This type cannot unbox to a native string" when not returning a `Str` from method `gist`
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 at -e line 1 > > ➜ class A { method gist { 42 } }; say A.new; > This type cannot unbox to a native string: P6opaque, Int > in block 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.
[perl #131238] [LTA] "This type cannot unbox to a native string" when not returning a `Str` from method `gist`
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 at -e line 1 > > ➜ class A { method gist { 42 } }; say A.new; > This type cannot unbox to a native string: P6opaque, Int > in block 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.
[perl #131238] [LTA] "This type cannot unbox to a native string" when not returning a `Str` from method `gist`
# New Ticket Created by Sam S. # Please include the string: [perl #131238] # in the subject line of all future correspondence about this issue. # https://rt.perl.org/Ticket/Display.html?id=131238 > 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 at -e line 1 ➜ class A { method gist { 42 } }; say A.new; This type cannot unbox to a native string: P6opaque, Int in block at -e line 1