# New Ticket Created by Elizabeth Mattijsen
# Please include the string: [perl #117875]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=117875 >
[20:30:33] <lizmat> rn: my enum Day <Mon Tue Wed Thu Fri Sat Sun>; say 3
~~ Day
[20:30:37] <+camelia> rakudo 88f9c9, niecza v24-37-gf9c8fc2: OUTPUT«False»
[20:31:12] <moritz_> rn: my enum Day <Mon Tue Wed Thu Fri Sat Sun>; say
Day(3).defined
[20:31:15] <+camelia> rakudo 88f9c9, niecza v24-37-gf9c8fc2: OUTPUT«True»
[20:31:20] <moritz_> rn: my enum Day <Mon Tue Wed Thu Fri Sat Sun>; say
Day(42).defined
[20:31:20] <lizmat> S12:1887 states: " 3 ~~ Day # True, using Day as
a subset of Int"
[20:31:23] <+camelia> niecza v24-37-gf9c8fc2: OUTPUT«Unhandled exception: No
match at /home/p6eval/niecza/lib/CORE.setting line 1504 (die @ 5)  at
/home/p6eval/niecza/lib/CORE.setting line 2103 (EnumMap._lookup @ 4)  at
/home/p6eval/niecza/lib/CORE.setting line 1308 (CommonEnum.postcircumfix:<( )>
@ 5)…
[20:31:23] <+camelia> ..rakudo 88f9c9: OUTPUT«False»
[20:31:43] <masak> rn: my enum Day <Mon Tue Wed Thu Fri Sat Sun>; say Day
~~ Int
[20:31:46] <+camelia> rakudo 88f9c9, niecza v24-37-gf9c8fc2: OUTPUT«True»
[20:32:03] <moritz_> can it be both a subtype and a subset?
[20:32:16] <moritz_> that sounds wrong to me
[20:32:40] <masak> enums are not subtypes, if by "subtype" you mean the
thing with the keyword "subset" in Perl 6.
[20:33:00] <moritz_> no, I meant "class that inherits from"
[20:33:08] <masak> it's also not a question of inheritance, since
infix:<~~> does lots of other things.
[20:33:17] <masak> well, not *necessarily* a question of inheritance.
[20:33:19] <jnthn> I suspect if you want to implement those semantics you
can get them by hacking on EnumHOW a bit
[20:33:43] lizmat is just trying things from the Synopses
[20:34:04] <jnthn> But what that working really means is "if you match
one of the enum value's underlying values it's good enough"
[20:34:51] <masak> yes, that was what I was after.
[20:35:00] <masak> it doesn't say how it's implemented.
[20:35:12] <lizmat> fwiw, 3 ~~ Thu works
[20:35:55] <lizmat> (as in: returns True)
[20:36:21] <jnthn> Well, it's kinda significant how you implement it in
so far as whether you expect to be able to pass 3 to a sub foo(Day $x) { }
[20:36:43] <masak> oh, sure.
[20:37:01] <moritz_> and if the callee can still expect all the goodness of
a Day object
[20:37:04] <jnthn> But I suspect "subtype" is being used a bit handwavily
in the spec there.
[20:37:06] <masak> jnthn: does that mean hacking ACCEPT won't be enough?
[20:37:20] <masak> er, ACCEPTS
[20:37:34] <jnthn> masak: Well, ACCEPTS for a :U invocant typically
delegates to the meta-object.
[20:37:44] <lizmat> jnthn: indeed
[20:37:48] <lizmat> rn: my enum Day <Mon Tue Wed Thu Fri Sat Sun>; sub foo
( Day $d ) { say "foo" }; foo(3)
[20:37:50] <+camelia> niecza v24-37-gf9c8fc2: OUTPUT«Potential
difficulties: $d is declared but not used at /tmp/ruUVS3HBNM line 1:------>
[32mTue Wed Thu Fri Sat Sun>; sub foo ( Day [33m⏏[31m$d ) { say "foo" };
foo(3)[0mUnhandled exception: Nominal type check failed in binding '$d' in
'foo'; got In…
[20:37:51] <+camelia> ..rakudo 88f9c9: OUTPUT«Nominal type check failed for
parameter '$d'; expected Day but got Int instead in sub foo at
/tmp/DQ6GB9NyWw:1 in block at /tmp/DQ6GB9NyWw:1»
[20:38:15] <jnthn> We can special-case ACCEPTS on :U for enum types I
guess.
[20:38:41] <masak> \o/
[20:38:42] <jnthn> But it'll drag it out of kilter with the usual
expectation that ~~ SomeType gives the same answer that a type check would on
binding.
[20:38:59] <jnthn> So we may want to tread carefully :)
[20:39:14] <lizmat> but this warrants a rakudobug, right ?
[20:39:24] <masak> absolutely.
[20:39:31] <masak> a NYI one, I guess.
[20:39:32] lizmat submits rakudobug