New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subtyped attributes can be instantiated with impossible values in Rakudo #999
Comments
From @masak<masak> perl6: class A { my subset B of Int where { $^n < 10 }; has B I would expect the instantiation to fail, because 20 is not a legit |
From @masak<jnthn> masak: In 65700 subset types are now enforced, but here we seem |
|
@masak - Status changed from 'new' to 'open' |
From @kylehaThis is an automatically generated mail to inform you that tests are now available in t/spec/S12-subset/subtypes.t commit 2859f31b0fc228bae3cdbfeac1a9688189582b7d [t/spec] Test for RT 65700, subtyped attributes in instantiation Inline Patchdiff --git a/t/spec/S12-subset/subtypes.t b/t/spec/S12-subset/subtypes.t
index 385621d..7eac46d 100644
--- a/t/spec/S12-subset/subtypes.t
+++ b/t/spec/S12-subset/subtypes.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 49;
+plan *;
=begin description
@@ -163,4 +163,22 @@ ok 42 ~~ NW1, 'subset declaration without where clause accepts right value';
ok 4.2 !~~ NW1, 'subset declaration without where clause rejects wrong value';
ok "x" !~~ NW1, 'subset declaration without where clause rejects wrong value';
+# RT #65700
+{
+ subset Small of Int where { $^n < 10 }
+ class RT65700 {
+ has Small $.small;
+ }
+ dies_ok { RT65700.new( small => 20 ) }, 'subset type is enforced as attribute in new() (1)';
+ lives_ok { RT65700.new( small => 2 ) }, 'subset type enforced as attribute in new() (2)';
+
+ my subset Teeny of Int where { $^n < 10 }
+ class T { has Teeny $.teeny }
+ #?rakudo 2 todo 'RT 65700'
+ dies_ok { T.new( small => 20 ) }, 'my subset type is enforced as attribute in new() (1)';
+ lives_ok { T.new( small => 2 ) }, 'my subset type enforced as attribute in new() (2)';
+}
+
+done_testing;
+
# vim: ft=perl6 |
From @cokeOn Mon Oct 26 14:50:37 2009, KyleHa wrote:
And we now run this test, with no skips or todos. \o/ -- |
|
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#65700 (status was 'resolved')
Searchable as RT65700$
The text was updated successfully, but these errors were encountered: