# New Ticket Created by  "Martin Berends" 
# Please include the string:  [perl #64046]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=64046 >


Unsure whether the following should work, but it doesn't:

perl6 -e 'enum E <foo bar>; my E $x=E::bar; given $x { when E::foo {say
"FOO"} when E::bar {say "BAR"}};'
Method 'ACCEPTS' not found for invocant of class ''

The problem seems to be that the 'when' cannot perform a smart match on an
enum member. A workaround is to cast the enum member to an int, but this
is surely not as intended:

perl6 -e 'enum E <foo bar>; my E $x=E::bar; given $x { when int E::foo
{say "FOO"} when int E::bar {say "BAR"}};'
BAR

The workaround is successful for example around line 442 etc of
http://github.com/eric256/perl6-examples/blob/master/lib/Pod/Parser.pm

See also: http://rt.perl.org/rt3/Public/Bug/Display.html?id=63878


Reply via email to