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

Rakudo gives incorrect output for subtypes #547

Closed
p6rt opened this issue Dec 27, 2008 · 5 comments
Closed

Rakudo gives incorrect output for subtypes #547

p6rt opened this issue Dec 27, 2008 · 5 comments

Comments

@p6rt
Copy link

p6rt commented Dec 27, 2008

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

Searchable as RT61776$

@p6rt
Copy link
Author

p6rt commented Dec 27, 2008

From publiustemp-perl6users@yahoo.com

  subset Letter of Str where { $_ =~ /^ <[a..z]> $/ };

  my $first_letter = 'a';
  say $first_letter;

  my Letter $second_letter = 'a';
  say $second_letter;

  sub doit (Letter $letter) {
  say $letter;
  }

  doit('a');

That outputs (_block69 is the second 'say' and the 'Cannot assign' is the sub call)​:

a
_block69
Cannot assign to readonly variable.
current instr.​: 'die' pc 14740 (src/builtins/control.pir​:204)
called from Sub 'infix​:=' pc 13106 (src/builtins/assign.pir​:24)
called from Sub '_block62' pc 310 (EVAL_14​:128)
called from Sub '!SUBTYPE_ACCEPTS' pc 15909 (src/builtins/guts.pir​:237)
called from Sub '!TYPECHECKPARAM' pc 15676 (src/builtins/guts.pir​:128)
called from Sub 'doit' pc 527 (EVAL_14​:212)
called from Sub '_block14' pc 200 (EVAL_14​:83)
called from Sub '!UNIT_START' pc 16073 (src/builtins/guts.pir​:327)
called from Sub 'parrot;PCT;HLLCompiler;eval' pc 892 (src/PCT/HLLCompiler.pir​:508)
called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1217 (src/PCT/HLLCompiler.pir​:669)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1398 (src/PCT/HLLCompiler.pir​:759)
called from Sub 'parrot;Perl6;Compiler;main' pc 18981 (perl6.pir​:162)
perl6(8003) malloc​: *** error for object 0x2bcc680​: double free
*** set a breakpoint in malloc_error_break to debug

My info​:

$ svn info; uname -a
Path​: .
URL​: https://svn.perl.org/parrot/trunk
Repository Root​: https://svn.perl.org/parrot
Repository UUID​: d31e2699-5ff4-0310-a27c-f18f2fbe73fe
Revision​: 34446
Node Kind​: directory
Schedule​: normal
Last Changed Author​: kjs
Last Changed Rev​: 34446
Last Changed Date​: 2008-12-27 21​:17​:55 +0000 (Sat, 27 Dec 2008)

Darwin curtis-poes-computer-3.local 9.5.1 Darwin Kernel Version 9.5.1​: Fri Sep 19 16​:19​:24 PDT 2008; root​:xnu-1228.8.30~1/RELEASE_I386 i386

--
Buy the book - http://www.oreilly.com/catalog/perlhks/
Tech blog - http://use.perl.org/~Ovid/journal/
Twitter - http://twitter.com/OvidPerl
Official Perl 6 Wiki - http://www.perlfoundation.org/perl6

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

From @jnthn

On Sat Dec 27 14​:08​:48 2008, publiustemp-perl6users@​yahoo.com wrote​:

subset Letter of Str where \{ $\_ =~ /^ \<\[a\.\.z\]> $/ \};

my $first\_letter = 'a';
say $first\_letter;

my Letter $second\_letter = 'a';
say $second\_letter;

sub doit \(Letter $letter\) \{
    say $letter;
\}

doit\('a'\);

That outputs (_block69 is the second 'say' and the 'Cannot assign' is
the sub call)​:

a
_block69
Cannot assign to readonly variable.

That's a Perl 5-o. :-) You likely meant​:

subset Letter of Str where { $_ ~~ /^ &lt;[a..z]&gt; $/ };

Which does work. But there are two issues​:

* We should implement the =~ check to give you a useful message about
this change. There's already a ticket for that one.

* I think both cases should give the "cannot assign to readonly
variable" warning because the $_ should be read-only inside that block.

So to resolve this ticket we should do the second of these.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

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

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

From @jnthn

On Fri Feb 13 10​:06​:37 2009, jnthn@​jnthn.net wrote​:

On Sat Dec 27 14​:08​:48 2008, publiustemp-perl6users@​yahoo.com wrote​:

subset Letter of Str where \{ $\_ =~ /^ \<\[a\.\.z\]> $/ \};

\.\.\.snip\.\.\.

That's a Perl 5-o. :-) You likely meant​:

subset Letter of Str where { $_ ~~ /^ &lt;[a..z]&gt; $/ };

...snip...

* I think both cases should give the "cannot assign to readonly
variable" warning because the $_ should be read-only inside that block.

So to resolve this ticket we should do the second of these.

And as of git 0f87695 this now fails with the read-only error in all
cases, not just the second one. (It may well segfault after giving the
error, but that's a Parrot issue that we already have plenty of open
tickets for, so resolving this one).

Plus added tests. :-)

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Feb 13, 2009

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

@p6rt p6rt closed this as completed Feb 13, 2009
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