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

Mis-matched types and Binding Containers - 2010.12 bug? #2321

Closed
p6rt opened this issue Jan 5, 2011 · 5 comments
Closed

Mis-matched types and Binding Containers - 2010.12 bug? #2321

p6rt opened this issue Jan 5, 2011 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Jan 5, 2011

Migrated from rt.perl.org#81682 (status was 'resolved')

Searchable as RT81682$

@p6rt
Copy link
Author

p6rt commented Jan 5, 2011

From james@rcpt.to

Hello,

I tried out the 2010.12 build of Raduko *, with a variation of the Perl
5 to 6 "Containers and Values" example
(http://perlgeek.de/en/article/5-to-6#post_10), testing for a handled
case when a typed Array is bound to a variable to a different type​:

  #!/usr/bin/perl6
  my Int @​a = 1, 2, 3;
  my Str $x = "foo";
  @​a[0] := $x;
  say @​a[0];

Gives the output (truncated)​:

  in 'at_pos' at line 5​:CORE.setting
  in 'Any​::postcircumfix​:<[ ]>' at line 1744​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'Any​::postcircumfix​:<[ ]>' at line 1744​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'Any​::postcircumfix​:<[ ]>' at line 1744​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'Any​::postcircumfix​:<[ ]>' at line 1744​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'Any​::postcircumfix​:<[ ]>' at line 1744​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'Any​::postcircumfix​:<[ ]>' at line 1744​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'at_pos' at line 5​:CORE.setting
  in 'Any​::postcircumfix​:<[ ]>' at line 1744​:CORE.setting

Not sure if this is already logged in RT. Playing further I see the saem
result when the types match​:

  #!/usr/bin/perl6
  my Int @​a = 1, 2, 3;
  my Int $x = 5;
  @​a[0] := $x;
  say @​a[0];

And also when the $x has no type​:

  #!/usr/bin/perl6
  my Int @​a = 1, 2, 3;
  my $x = 5;
  @​a[0] := $x;
  say @​a[0];

The only time this works is when @​a is not typed at all; $x can be
typed, but doesnt have to be for this example to work​:

  #!/usr/bin/perl6
  my @​a = 1, 2, 3;
  my Int $x = 5;
  @​a[0] := $x;
  say @​a[0];

So, perhaps when @​a is typed to only be INTs, it cannot hold Containers,
and the error is not caught?

HTH. Many thanks,

  James

PS​: Is there any use to getting Unicode character "one half" (½), "one
quarter" (¼) and "three quarters" (¾) to be recognised for the rational
numerical value they represent. Such that "½ * 2 == 1", and "½ / ½ ==
¼"? I tried to define a "sub ¼ { return 0.25;}" but that didn't work.... :)

@p6rt
Copy link
Author

p6rt commented Nov 20, 2012

From @FROGGS

looks good today​:

<FROGGS> r​: my Int @​a = 1, 2, 3; my Str $x = "foo"; @​a[0] := $x; say @​a[0];
<p6eval> rakudo bf472b​: OUTPUT«foo␤»

<FROGGS> r​: my Int @​a = 1, 2, 3; my Int $x = 5; @​a[0] := $x; say @​a[0];
<p6eval> rakudo bf472b​: OUTPUT«5␤»

<FROGGS> r​: my Int @​a = 1, 2, 3; my $x = 5; @​a[0] := $x; say @​a[0];
<p6eval> rakudo bf472b​: OUTPUT«5␤»

<FROGGS> r​: my @​a = 1, 2, 3; my Int $x = 5; @​a[0] := $x; say @​a[0];
<p6eval> rakudo bf472b​: OUTPUT«5␤»

@p6rt
Copy link
Author

p6rt commented Nov 20, 2012

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

@p6rt
Copy link
Author

p6rt commented Jun 30, 2015

From @usev6

On Tue Nov 20 12​:16​:04 2012, FROGGS.de wrote​:

looks good today​:

<FROGGS> r​: my Int @​a = 1, 2, 3; my Str $x = "foo"; @​a[0] := $x; say @​a[0];
<p6eval> rakudo bf472b​: OUTPUT«foo␤»

<FROGGS> r​: my Int @​a = 1, 2, 3; my Int $x = 5; @​a[0] := $x; say @​a[0];
<p6eval> rakudo bf472b​: OUTPUT«5␤»

<FROGGS> r​: my Int @​a = 1, 2, 3; my $x = 5; @​a[0] := $x; say @​a[0];
<p6eval> rakudo bf472b​: OUTPUT«5␤»

<FROGGS> r​: my @​a = 1, 2, 3; my Int $x = 5; @​a[0] := $x; say @​a[0];
<p6eval> rakudo bf472b​: OUTPUT«5␤»

The output is still the same as in 2012. I guess, this ticket hasn't been closed because the first command should actually die with X​::TypeCheck.

The other commands are fine, though. I added a test for those to S09-typed-arrays/arrays.t with commit Raku/roast@8dd0ebb164

Since we have another ticket (https://rt-archive.perl.org/perl6/Ticket/Display.html?id=123769) for the "should crash" case, I'm linking both tickets and closing this one as 'resolved'.

On Wed Jan 05 07​:01​:52 2011, james@​rcpt.to wrote​:

PS​: Is there any use to getting Unicode character "one half" (½), "one
quarter" (¼) and "three quarters" (¾) to be recognised for the rational
numerical value they represent. Such that "½ * 2 == 1", and "½ / ½ ==
¼"? I tried to define a "sub ¼ { return 0.25;}" but that didn't work.... :)

BTW, there was an answer to this question about Unicode characters like ½ on #perl6 just today​:

< TimToady> m​: constant term​:<½> = 1/2; say ½
<+camelia> rakudo-moar 7b5256​: OUTPUT«0.5␤»
< TimToady> thing is, ½ is not alphanumeric
< TimToady> m​: say '½' ~~ /\w/
<+camelia> rakudo-moar 7b5256​: OUTPUT«Nil␤»
< TimToady> and only alphanumerics get treated as identifier fodder
< TimToady> so any other term has to use the term​:<> notation, just as you'd use infix​:<> and such

@p6rt
Copy link
Author

p6rt commented Jun 30, 2015

@usev6 - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant