Skip to content
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

defined value as type constraint has inconsistent behaviour #4867

Open
p6rt opened this issue Dec 13, 2015 · 1 comment
Open

defined value as type constraint has inconsistent behaviour #4867

p6rt opened this issue Dec 13, 2015 · 1 comment
Labels
Bug

Comments

@p6rt
Copy link

@p6rt p6rt commented Dec 13, 2015

Migrated from rt.perl.org#126906 (status was 'new')

Searchable as RT126906$

@p6rt

This comment has been minimized.

Copy link
Author

@p6rt p6rt commented Dec 13, 2015

From zefram@fysh.org

If a defined value is used as a type constraint, the values that the
constraint will accept are inconsistent between using the type constraint
on a variable and using it on a sub parameter​:

constant T = 3
3
3.^isa(T)
0
(sub (T $a) { 1 })(3)
1
my T $a = 3
Type check failed in assignment to $a; expected 3 but got 3
  in block <unit> at <unknown file>​:1

The two type constraint situations are consistent in disallowing other
values such as 2, "foo", and Int. It probably should not be permitted
at all to use anything other than a type object as a type constraint.
See also [perl #​126117].

-zefram

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.