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

Problems with scalar assignment of Nil #2446

Closed
p6rt opened this issue Jul 3, 2011 · 4 comments
Closed

Problems with scalar assignment of Nil #2446

p6rt opened this issue Jul 3, 2011 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jul 3, 2011

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

Searchable as RT93980$

@p6rt
Copy link
Author

p6rt commented Jul 3, 2011

From @ronaldxs

From the IRC discussion​:
http://irclog.perlgeek.de/perl6/2011-07-03#i_4051503

13​:49 TimToady
  nom​: my Str $a = Nil;
13​:49 p6eval
  nom​: OUTPUT«Type check failed in assignment to '$a'; expected 'Str' but got 'Nil'␤current instr.​: '_block1002' pc 28 ((file unknown)​:0) (​:1)␤»
13​:50 TimToady
  rakudo​: my Str $a = Nil;
13​:50 p6eval
  rakudo 72d158​: OUTPUT«Type check failed for assignment␤ Container type​: Str␤ Got​: Nil␤ in '&infix​:<=>' at line 1​:src/metamodel/RoleToInstanceApplier.nqp␤ in main program body at line 22​:/tmp/jK7jxCEjPS␤»
13​:50 * TimToady
  is a bit surprised that fails
13​:56 PhatEddy
  The case of of not enough initializers I thought I understood well enough for a bug report but I am less sure of the scalar assignment to Nil. I am guessing scalar assignment to nil usually does nothing?
13​:57 s/to nil/from nil/
13​:58 TimToady
  see S02​:2240

S02​:2240 reads in part - Assigning C<Nil> to any scalar container causes the
container to throw out any contents and restore itself to an
uninitialized state (after which it will contain a type object
appropriate to the declared type of the container, where C<Any>
is the default type).

Also note​:

14​:05 PhatEddy
  nom​: my $x = Nil; say $x.perl
14​:05 p6eval
  nom​: OUTPUT«Nil␤»
14​:05 PhatEddy
  rakudo​: my $x = Nil; say $x.perl
14​:05 p6eval
  rakudo 72d158​: OUTPUT«Any␤»
14​:06 PhatEddy
  rakudo is OK here I'm guessing ...
14​:06 TimToady
  yes

@p6rt
Copy link
Author

p6rt commented Mar 22, 2012

From @masak

<masak> p6​: my Str $s = "OH HAI"; $s = Nil; say $s
<p6eval> rakudo 1a468d​: OUTPUT«Type check failed in assignment to
'$s'; expected 'Str' but got 'Nil' [...]
<p6eval> ..niecza v15-4-g1f35f89​: OUTPUT«Str()␤»
* masak submits rakudobug

S02​:2265​:

"Assigning C<Nil> to any scalar container causes the container to
throw out any contents and restore itself to an uninitialized state
(after which it will contain an object appropriate to the declared
default of the container, where C<Any> is the default default)."

@p6rt
Copy link
Author

p6rt commented Aug 13, 2013

From @moritz

The tests in S02-types/nil.t pass now, so I think this is fixed.

@p6rt
Copy link
Author

p6rt commented Aug 13, 2013

@moritz - Status changed from 'new' 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