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

changed type of variable #6311

Closed
p6rt opened this issue Jun 3, 2017 · 8 comments
Closed

changed type of variable #6311

p6rt opened this issue Jun 3, 2017 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Jun 3, 2017

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

Searchable as RT131493$

@p6rt
Copy link
Author

p6rt commented Jun 3, 2017

From @MARTIMM

Hi,

In Rakudo version 2017.05-338-gaca1929 built on MoarVM version
2017.05-25-g62bc54e
implementing Perl 6.c I saw that a type could be changed through an
assignment which It should not do. In REPL;

my Str $s = IntStr.new(12,'12');
12
$s.WHAT
(IntStr)

The type IntStr should be coerced into Str. A second example happened in
my code and golfed in REPL

sub s (Str :$str) {say $str.WHAT}
sub s (Str :$str) { #`(Sub|89412592) ... }
s(​:str<1>)
(IntStr)
s(​:str<a>)
(Str)

The type should stay as it was defined I think.
Marcel

@p6rt
Copy link
Author

p6rt commented Jun 3, 2017

From @AlexDaniel

Well,

say IntStr ~~ Str   # True

In other words, IntStr *is* a Str.

What I find interesting, however, is this difference​:

sub s (Str() :$str) {say $str.WHAT}; s(​:str<1>) # IntStr
sub s (Str :$str) {say $str.Str.WHAT}; s(​:str<1>) # Str

I would have expected the same output in both cases.

On 2017-06-03 02​:05​:49, mt1957@​gmail.com wrote​:

Hi,

In Rakudo version 2017.05-338-gaca1929 built on MoarVM version
2017.05-25-g62bc54e
implementing Perl 6.c I saw that a type could be changed through an
assignment which It should not do. In REPL;

my Str $s = IntStr.new(12,'12');
12
$s.WHAT
(IntStr)

The type IntStr should be coerced into Str. A second example happened in
my code and golfed in REPL

sub s (Str :$str) {say $str.WHAT}
sub s (Str :$str) { #`(Sub|89412592) ... }
s(​:str<1>)
(IntStr)
s(​:str<a>)
(Str)

The type should stay as it was defined I think.
Marcel

@p6rt
Copy link
Author

p6rt commented Jun 3, 2017

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

@p6rt
Copy link
Author

p6rt commented Jun 3, 2017

From @MARTIMM

On 06/03/2017 11​:36 AM, Aleks-Daniel Jakimenko-Aleksejev via RT wrote​:

say IntStr ~~ Str

say Str ~~ IntStr
False

@p6rt
Copy link
Author

p6rt commented Jun 3, 2017

From @MARTIMM

On 06/03/2017 11​:36 AM, Aleks-Daniel Jakimenko-Aleksejev via RT wrote​:

sub s (Str() :$str) {say $str.WHAT}; s(​:str<1>) # IntStr
sub s (Str :$str) {say $str.Str.WHAT}; s(​:str<1>) # Str

I think the last one is coerced explicitly. Btw I didn't know about
'Str() :$str' specification. What does it do?

The previous mail about the type test 'say Str ~~ IntStr' I meant that
this is the test what the coercion to Str should force isn't it?

Marcel

@p6rt
Copy link
Author

p6rt commented Jun 3, 2017

From @MARTIMM

After some discussion I've understood that I have to do some homework
and that this bug can be closed. Thanks Jnhtn and Araraloren for your help

Regards,
Marcel

@p6rt
Copy link
Author

p6rt commented Jun 4, 2017

From @zoffixznet

On Sat, 03 Jun 2017 07​:52​:09 -0700, mt1957@​gmail.com wrote​:

this bug can be closed

OK. Closing.

On Sat, 03 Jun 2017 02​:36​:12 -0700, alex.jakimenko@​gmail.com wrote​:

Well,

say IntStr ~~ Str # True

In other words, IntStr *is* a Str.

What I find interesting, however, is this difference​:

sub s (Str() :$str) {say $str.WHAT}; s(​:str<1>) # IntStr
sub s (Str :$str) {say $str.Str.WHAT}; s(​:str<1>) # Str

I would have expected the same output in both cases.

It's a bit involved. I opened a separate @​LARRY ticket​:
https://rt-archive.perl.org/perl6/Ticket/Display.html?id=131505

@p6rt
Copy link
Author

p6rt commented Jun 4, 2017

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

@p6rt p6rt closed this as completed Jun 4, 2017
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