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

Enum value matching type name obliterates said name for that type. #5466

Closed
p6rt opened this issue Jul 19, 2016 · 5 comments
Closed

Enum value matching type name obliterates said name for that type. #5466

p6rt opened this issue Jul 19, 2016 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Jul 19, 2016

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

Searchable as RT128667$

@p6rt
Copy link
Author

p6rt commented Jul 19, 2016

From @ShimmerFairy

$ perl6 -e 'say Int.WHAT; enum A <B C Int>; say Int.WHAT'
(Int)
(A)

Note that the original type is still available under CORE​:

$ perl6 -e 'say Int.WHAT; enum A <B C Int>; say CORE​::Int.WHAT'
(Int)
(Int)

But this ruins more than just what name you can use​:

$ perl6 -e 'enum A <B C Int>; say 42'
===SORRY!===
Cannot unbox a type object

I found this bug when coming across this error​:

$ perl6 -e 'enum A <B Enumeration>; enum C <D E>;'
===SORRY!=== Error while compiling -e
Cannot resolve caller trait_mod​:<does>(C, A); none of these signatures match​:
  (Mu​:U $doee, Mu​:U $role)
  (Variable​:D $v, Mu​:U $role)
at -e​:1

The proper solution would be to not try to take that global in this case, and/or to allow the user to specify they don't want to pollute the global namespace in the first place.

@p6rt
Copy link
Author

p6rt commented Jul 19, 2016

From @zoffixznet

Hi,

Thanks for the report.

That's really a language feature​: being able to shadow core things. It works in many other places too​:

<Zoffix> m​: say Str.WHAT; my \Str = 42; say Str.WHAT
<camelia> rakudo-moar 6757a8​: OUTPUT«(Str)␤(Int)␤»
<Zoffix> m​: sub say (*@​) { put "No, I won't say!" }; say 42
<camelia> rakudo-moar 6757a8​: OUTPUT«No, I won't say!␤»

You also mentioned that it's a global effect, but it's actually lexical.

Keeping in mind that shadowing core stuff is a feature not a bug, should this ticket be closed or do you think there's still an improvement to be made? If yes, what is it?

--
Cheers,
ZZ | https://twitter.com/zoffix

@p6rt
Copy link
Author

p6rt commented Jul 19, 2016

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

@p6rt
Copy link
Author

p6rt commented Aug 16, 2016

From @zoffixznet

Closing per explanation above.

@p6rt
Copy link
Author

p6rt commented Aug 16, 2016

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

@p6rt p6rt closed this as completed Aug 16, 2016
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