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

perl6-p fails using @array.gist on array defined as a named parameter to a method #3466

Closed
p6rt opened this issue Jul 30, 2014 · 7 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Jul 30, 2014

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

Searchable as RT122440$

@p6rt
Copy link
Author

p6rt commented Jul 30, 2014

From andynparker@googlemail.com

Hello,

  I have the following failure from Rakudo 2014-04 when running some
tests​:

ok 4 - LDAP object out of scope should be true.

setData - array uri called, public API. in method setData
at /home/aparker/Documents/LDAP/lib/LDAP.pm6​:139

Type check failed in assignment to '@​uri'; expected 'Str' but got
'Array'
  in method REIFY at gen/parrot/CORE.setting​:8667
  in method reify at gen/parrot/CORE.setting​:7511
  in method reify at gen/parrot/CORE.setting​:7498
  in method reify at gen/parrot/CORE.setting​:7596
  in method reify at gen/parrot/CORE.setting​:7498
  in method reify at gen/parrot/CORE.setting​:7498
  in method gimme at gen/parrot/CORE.setting​:7962
  in method eager at gen/parrot/CORE.setting​:7934
  in method join at gen/parrot/CORE.setting​:1637
  in method perl at gen/parrot/CORE.setting​:8754
  in method perl at gen/parrot/CORE.setting​:1060
  in method perl at gen/parrot/CORE.setting​:8812
  in method perl at gen/parrot/CORE.setting​:1060
  in method gist at gen/parrot/CORE.setting​:9200
  in method gist at gen/parrot/CORE.setting​:1056
  in method setData at /home/aparker/Documents/LDAP/lib/LDAP.pm6​:146
  in method setData at gen/parrot/CORE.setting​:542
  in block at 00-ctests.t​:57

# Looks like you planned 44 tests, but ran 4

Code in the test data is​:

my Str @​uri = (
  [<ldap​://ab21a.abcdf.com​:6666/o=University%20of%
20Michigan,c=US??sub?(cn=Babs%20Jensen)>],
  [<ldap​://ab21a.abcdf.com​:6666/o=University%20of%
20Michigan,c=US??sub?(cn=Babs%20Jensen)>],
  [<ldap​://ab21a.abcdf.com​:6666/o=University%20of%
20Michigan,c=US??sub?(cn=Babs%20Jensen)>],
  ) ;

An array definition with string data (mail client has messed up a little
here).

Call in test data is​:
my $errObj1 = $LDAPinstance1.setData( uri => @​uri ); (This is line 57 in
the tests.)

System correctly runs the right multi method, which is coded​:

multi method setData( Str :@​uri!, <==== This 'Str' causes the issue.
  Str :$iAm,
  IO​::Path :$libName = $libNameDefault,
  ) {
 
  # Debugging!
  warn 'setData - array uri called, public API.'
  if %*ENV<DEBUG>;
 
  # Create a hash of all possible parameters.
  my %params =
  iAm => $iAm, libName => $libName, uri => @​uri,
  ;
  say %params.gist; <====================== Fails here!
  This is line 146.
 
  # Debugging! - list all input data.
  if %*ENV<DEBUG> {
  my $g = %params.perl;
  warn 'setData - array uri %params =' ~ $g ~ '.';
  }
 
  # Validate the passed data items.
  my $errObj = self!setDataParams( %params );
  return $errObj;
}

or is this just my bad code? Removing the "array of strings"
definition removes the problem; but I rather like type
definitions! B-)

Many thanks,

Andrew N Parker

@p6rt
Copy link
Author

p6rt commented Jul 30, 2014

@p6rt
Copy link
Author

p6rt commented Mar 15, 2015

From @usev6

On Wed Jul 30 07​:33​:05 2014, andynparker@​googlemail.com wrote​:

Hello,

I have the following failure from Rakudo 2014\-04 when running some

tests​:

ok 4 - LDAP object out of scope should be true.

setData - array uri called, public API. in method setData
at /home/aparker/Documents/LDAP/lib/LDAP.pm6​:139

Type check failed in assignment to '@​uri'; expected 'Str' but got
'Array'
in method REIFY at gen/parrot/CORE.setting​:8667
in method reify at gen/parrot/CORE.setting​:7511
in method reify at gen/parrot/CORE.setting​:7498
in method reify at gen/parrot/CORE.setting​:7596
in method reify at gen/parrot/CORE.setting​:7498
in method reify at gen/parrot/CORE.setting​:7498
in method gimme at gen/parrot/CORE.setting​:7962
in method eager at gen/parrot/CORE.setting​:7934
in method join at gen/parrot/CORE.setting​:1637
in method perl at gen/parrot/CORE.setting​:8754
in method perl at gen/parrot/CORE.setting​:1060
in method perl at gen/parrot/CORE.setting​:8812
in method perl at gen/parrot/CORE.setting​:1060
in method gist at gen/parrot/CORE.setting​:9200
in method gist at gen/parrot/CORE.setting​:1056
in method setData at /home/aparker/Documents/LDAP/lib/LDAP.pm6​:146
in method setData at gen/parrot/CORE.setting​:542
in block at 00-ctests.t​:57

# Looks like you planned 44 tests, but ran 4

Code in the test data is​:

my Str @​uri = (
[<ldap​://ab21a.abcdf.com​:6666/o=University%20of%
20Michigan,c=US??sub?(cn=Babs%20Jensen)>],
[<ldap​://ab21a.abcdf.com​:6666/o=University%20of%
20Michigan,c=US??sub?(cn=Babs%20Jensen)>],
[<ldap​://ab21a.abcdf.com​:6666/o=University%20of%
20Michigan,c=US??sub?(cn=Babs%20Jensen)>],
) ;

An array definition with string data (mail client has messed up a little
here).

Call in test data is​:
my $errObj1 = $LDAPinstance1.setData( uri => @​uri ); (This is line 57 in
the tests.)

System correctly runs the right multi method, which is coded​:

multi method setData( Str :@​uri!, <==== This 'Str' causes the issue.
Str :$iAm,
IO​::Path :$libName = $libNameDefault,
) {

# Debugging!
warn 'setData - array uri called, public API.'
if %*ENV<DEBUG>;

# Create a hash of all possible parameters.
my %params =
iAm => $iAm, libName => $libName, uri => @​uri,
;
say %params.gist; <====================== Fails here!
This is line 146.

# Debugging! - list all input data.
if %*ENV<DEBUG> {
my $g = %params.perl;
warn 'setData - array uri %params =' ~ $g ~ '.';
}

# Validate the passed data items.
my $errObj = self!setDataParams( %params );
return $errObj;
}

or is this just my bad code? Removing the "array of strings"
definition removes the problem; but I rather like type
definitions! B-)

Many thanks,

Andrew N Parker

Hi,

it's been quite a while since you opened this bug report. Nonetheless, today I tried to reproduce the problem you described.

It looks to me as if the assignment to @​uri (your test data) is to blame for the error you see. I'll shorten the ldap uris to demonstrate​:

$ perl6 -e 'my @​uri = ( [<ldap1>], [<ldap2>]); say @​uri.perl; say @​uri[0].WHAT; say @​uri[0].perl; say @​uri[0][0].WHAT; say @​uri[0][0].perl'
Array.new(["ldap1"], ["ldap2"])
(Array)
["ldap1"]
(Str)
"ldap1"

So this is not an Array of Str, but an Array of Array. If you remove the square brackets from your test data, you really get an Array of Str​:

$ perl6 -e 'my @​uri = ( <ldap1>, <ldap2>); say @​uri.perl; say @​uri[0].WHAT; say @​uri[0].perl;'
Array.new("ldap1", "ldap2")
(Str)
"ldap1"

With that data IMHO you shouldn't get the error message you encountered.

The underlying problem seems to be a bug in Rakudo​: The assignment to @​uri with a type constraint should result in an exception X​::TypeCheck​::Assignment if the type doesn't match. That indeed happens, when you call your assignment on its own​:

$ perl6 -e 'my Str @​uri = ( [<ldap1>], [<ldap2>])'
Unhandled exception​: Type check failed in assignment to '@​uri'; expected 'Str' but got 'Array'
  at <unknown>​:1 (././CORE.setting.moarvm​:throw​:4294967295)
[...]

But -- and that's the bug -- when the assignment is followed by some other code, this doesn't blow up. That's what seems to happen in your program. (It blows up later when you use your method 'setData'.

$ perl6 -e 'my Str @​uri = ( [<ldap1>], [<ldap2>]); say "alive"'
alive

I'm going to open a separate bug report for this assignment not blowing up.

Best regards

Christian

@p6rt
Copy link
Author

p6rt commented Mar 15, 2015

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

@p6rt
Copy link
Author

p6rt commented Sep 1, 2015

From @usev6

The underlying bug in Rakudo I spoke about is now fixed (in the 'glr' branch). There is a test in roast -- cmp. Ticket 124079 (https://rt-archive.perl.org/perl6/Ticket/Display.html?id=124079). The shortened code from the bug report dies as expected​:

$ perl6 -e 'my Str @​uri = ([<ldap1>], [<ldap2>]); say "alive"'
Type check failed in assignment to '@​uri'; expected 'Str' but got 'Array'
  in block <unit> at -e​:1

I'm closing this ticket as 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Sep 1, 2015

From @usev6

The underlying bug in Rakudo I spoke about is now fixed (in the 'glr' branch). There is a test in roast -- cmp. Ticket 124079 (https://rt-archive.perl.org/perl6/Ticket/Display.html?id=124079). The shortened code from the bug report dies as expected​:

$ perl6 -e 'my Str @​uri = ([<ldap1>], [<ldap2>]); say "alive"'
Type check failed in assignment to '@​uri'; expected 'Str' but got 'Array'
  in block <unit> at -e​:1

I'm closing this ticket as 'resolved'.

@p6rt p6rt closed this as completed Sep 1, 2015
@p6rt
Copy link
Author

p6rt commented Sep 1, 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant