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

combining :D, a where clause and Nil results in empty type object #5477

Closed
p6rt opened this issue Jul 23, 2016 · 4 comments
Closed

combining :D, a where clause and Nil results in empty type object #5477

p6rt opened this issue Jul 23, 2016 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jul 23, 2016

Migrated from rt.perl.org#128710 (status was 'rejected')

Searchable as RT128710$

@p6rt
Copy link
Author

p6rt commented Jul 23, 2016

From @gfldex

sub niler{Nil}; my Int​:D $i where .defined = niler(); say $i; say $i.WHAT;
# OUTPUT«(<anon>)␤(<anon>)␤»
# expected​: well, I don't know since I explicitely asked for a defined
# value _twice_ but Nil is supposed to revert a container to it's default.
# That default is undefined, what can't work with $_.defined and should
# work (by design, not my opinion) with :D.
# Either way, I would like to get a type object when asking for WHAT.
# may be related to RT#​127958

@p6rt
Copy link
Author

p6rt commented Jan 20, 2018

From @zoffixznet

On Sat, 23 Jul 2016 15​:57​:33 -0700, gfldex wrote​:

sub niler{Nil}; my Int​:D $i where .defined = niler(); say $i; say $i.WHAT;
# OUTPUT«(<anon>)␤(<anon>)␤»
# expected​: well, I don't know since I explicitely asked for a defined
# value _twice_ but Nil is supposed to revert a container to it's default.
# That default is undefined, what can't work with $_.defined and should
# work (by design, not my opinion) with :D.
# Either way, I would like to get a type object when asking for WHAT.
# may be related to RT#​127958

Thanks for the report.

It's not empty. In both cases it says "<anon>", because you've used a `where` clause, thus creating an anonymous (nameless) subset.

If you prefer it to have a name, you can define a named subset instead​:

  <Zoffix__> m​: my Int $i where 42; say $i;
  <camelia> rakudo-moar bfb5279aa​: OUTPUT​: «(<anon>)␤»
  <Zoffix__> m​: subset Foo of Int where 42; my Foo $i ; say $i;
  <camelia> rakudo-moar bfb5279aa​: OUTPUT​: «(Foo)␤»

I made a patch that makes it say "<Int-based anon subset>" instead, but in the end decided against it,
because we use '<anon>' in many other places and this breaks that consistency, without adding much of extra information.

[1] https://gist.github.com/zoffixznet/198403153020a20b427bb2088b118ecc

Closing this as wontfix.

@p6rt
Copy link
Author

p6rt commented Jan 20, 2018

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

@p6rt
Copy link
Author

p6rt commented Jan 20, 2018

@zoffixznet - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Jan 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant