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

definedness constraint ignored on native type #4576

Open
p6rt opened this issue Sep 21, 2015 · 4 comments
Open

definedness constraint ignored on native type #4576

p6rt opened this issue Sep 21, 2015 · 4 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Sep 21, 2015

Migrated from rt.perl.org#126135 (status was 'open')

Searchable as RT126135$

@p6rt
Copy link
Author

p6rt commented Sep 21, 2015

From zefram@fysh.org

$ ./perl6 -e 'sub aa(int​:U $i) { say $i; }; aa(3); aa(int)'
3
Cannot unbox a type object
  in sub aa at -e​:1
  in block <unit> at -e​:1

The definedness constraint qualifiers :D and :U are ignored for the int
type, even though in this context of a parameter declaration they work
for most types. This is misleading. The qualifiers should signal an
error in this situation, unless and until they are implemented so as to
have the obvious effect.

-zefram

@p6rt
Copy link
Author

p6rt commented Sep 23, 2015

From @jnthn

On Mon Sep 21 11​:22​:24 2015, zefram@​fysh.org wrote​:

$ ./perl6 -e 'sub aa(int​:U $i) { say $i; }; aa(3); aa(int)'
3
Cannot unbox a type object
in sub aa at -e​:1
in block <unit> at -e​:1

The definedness constraint qualifiers :D and :U are ignored for the int
type, even though in this context of a parameter declaration they work
for most types. This is misleading. The qualifiers should signal an
error in this situation, unless and until they are implemented so as to
have the obvious effect.

A native type cannot hold an undefined value, so writing :U should be a compile time error (it could never match, so probably indicates confusion). May as well do similar for :D.

/jnthn

@p6rt
Copy link
Author

p6rt commented Sep 23, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 24, 2015

From zefram@fysh.org

jnthn@​jnthn.net via RT wrote​:

A native type cannot hold an undefined value, so writing :U should
be a compile time error (it could never match

I would expect the type object (int) to match the notional int​:U
constraint. Rakudo is quite clear that (int) isa int, and obviously
it's not defined in the relevant sense.

$ ./perl6 -e 'say int ~~ int; say int.defined'
True
False

This side of native types runs into [perl #​126116], regarding inconsistent
behaviour about whether the type object is allowed into a native-typed
variable.

-zefram

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant