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

Array of Hash conversion and type check error and unexpected conversion to pair #3380

Closed
p6rt opened this issue May 6, 2014 · 5 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented May 6, 2014

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

Searchable as RT121804$

@p6rt
Copy link
Author

p6rt commented May 6, 2014

From @teodozjan

Hi,

I found some hash issues on moar and parrot

perl6-p --version
This is perl6 version 2014.04-181-gf374d87 built on parrot 6.1.0
revision RELEASE_6_1_0
perl6 --version
This is perl6 version 2014.04-181-gf374d87 built on MoarVM version
2014.04-49-gaa7bbef

sub y returns Array of Hash{
  my %a1 = :x("y"), :y("z"), :w("c");
  my %a2 =​:x("y"), :y("t"), :w("c");
  my %a3 = :x("y"), :y("z"), :w("h");

  my Hash $b1 = %a1;
  my Hash $b2 = %a2;
  my Hash $b3 = %a3;
  say $b1.WHAT;
  my Hash @​array = $b1,$b2,$b3;
}
y;
perl6 ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got 'Array[Hash]'
  in any return_error at src/vm/moar/Perl6/Ops.nqp​:598
  in sub y at /home/kamil/dev/sandbox/HashKing.pl​:27
  in block at /home/kamil/dev/sandbox/HashKing.pl​:30

perl6-p ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got 'Array[Hash]'
  in sub y at /home/kamil/dev/sandbox/HashKing.pl​:27
  in block at /home/kamil/dev/sandbox/HashKing.pl​:30

sub x returns Array of Hash{
  my %a1 = :x("y"), :y("z"), :w("c");
  my %a2 =​:x("y"), :y("t"), :w("c");
  my %a3 = :x("y"), :y("z"), :w("h");
  say %a1.WHAT;
  my Hash @​array = %a1,%a2,%a3;
}
x;

$ perl6 ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed in assignment to '@​array'; expected 'Hash' but got 'Pair'
  in method REIFY at src/gen/m-CORE.setting​:8775
  in method reify at src/gen/m-CORE.setting​:7611
  in method gimme at src/gen/m-CORE.setting​:8049
  in method sink at src/gen/m-CORE.setting​:8473
  in method BUILDALL at src/gen/m-CORE.setting​:939
  in method bless at src/gen/m-CORE.setting​:858
  in method new at src/gen/m-CORE.setting​:843
  in any return_error at src/vm/moar/Perl6/Ops.nqp​:598
  in sub x at /home/kamil/dev/sandbox/HashKing.pl​:8
  in block at /home/kamil/dev/sandbox/HashKing.pl​:15

$ perl6-p ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got 'Array[Hash]'
  in sub y at /home/kamil/dev/sandbox/HashKing.pl​:27
  in block at /home/kamil/dev/sandbox/HashKing.pl​:30

--
Pozdrawiam

Kamil Ku�aga

@p6rt
Copy link
Author

p6rt commented May 6, 2014

From @teodozjan

Sorry for wrong output. For x method on parrot should be​:
$ perl6-p ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got 'Array[Hash]'
  in sub x at /home/kamil/dev/sandbox/HashKing.pl​:8
  in block at /home/kamil/dev/sandbox/HashKing.pl​:15

Anyway only linenumbers and method name change.

On Tue, May 6, 2014 at 11​:27 AM, perl6 via RT
<perl6-bugs-followup@​perl.org> wrote​:

Greetings,

This message has been automatically generated in response to the
creation of a trouble ticket regarding​:
"[BUG]Array of Hash conversion and type check error and unexpected conversion to pair",
a summary of which appears below.

There is no need to reply to this message right now. Your ticket has been
assigned an ID of [perl #​121804].

Please include the string​:

     \[perl #&#8203;121804\]

in the subject line of all future correspondence about this issue. To do so,
you may reply to this message.

                    Thank you,
                    perl6\-bugs\-followup@&#8203;perl\.org

-------------------------------------------------------------------------
Hi,

I found some hash issues on moar and parrot

perl6-p --version
This is perl6 version 2014.04-181-gf374d87 built on parrot 6.1.0
revision RELEASE_6_1_0
perl6 --version
This is perl6 version 2014.04-181-gf374d87 built on MoarVM version
2014.04-49-gaa7bbef

sub y returns Array of Hash{
my %a1 = :x("y"), :y("z"), :w("c");
my %a2 =​:x("y"), :y("t"), :w("c");
my %a3 = :x("y"), :y("z"), :w("h");

my Hash $b1 = %a1;
my Hash $b2 = %a2;
my Hash $b3 = %a3;
say $b1\.WHAT;
my Hash @&#8203;array = $b1,$b2,$b3;

}
y;
perl6 ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got 'Array[Hash]'
in any return_error at src/vm/moar/Perl6/Ops.nqp​:598
in sub y at /home/kamil/dev/sandbox/HashKing.pl​:27
in block at /home/kamil/dev/sandbox/HashKing.pl​:30

perl6-p ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got 'Array[Hash]'
in sub y at /home/kamil/dev/sandbox/HashKing.pl​:27
in block at /home/kamil/dev/sandbox/HashKing.pl​:30

sub x returns Array of Hash{
my %a1 = :x("y"), :y("z"), :w("c");
my %a2 =​:x("y"), :y("t"), :w("c");
my %a3 = :x("y"), :y("z"), :w("h");
say %a1.WHAT;
my Hash @​array = %a1,%a2,%a3;
}
x;

$ perl6 ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed in assignment to '@​array'; expected 'Hash' but got 'Pair'
in method REIFY at src/gen/m-CORE.setting​:8775
in method reify at src/gen/m-CORE.setting​:7611
in method gimme at src/gen/m-CORE.setting​:8049
in method sink at src/gen/m-CORE.setting​:8473
in method BUILDALL at src/gen/m-CORE.setting​:939
in method bless at src/gen/m-CORE.setting​:858
in method new at src/gen/m-CORE.setting​:843
in any return_error at src/vm/moar/Perl6/Ops.nqp​:598
in sub x at /home/kamil/dev/sandbox/HashKing.pl​:8
in block at /home/kamil/dev/sandbox/HashKing.pl​:15

$ perl6-p ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got 'Array[Hash]'
in sub y at /home/kamil/dev/sandbox/HashKing.pl​:27
in block at /home/kamil/dev/sandbox/HashKing.pl​:30

--
Pozdrawiam

Kamil Ku�aga

--
Pozdrawiam

Kamil Ku�aga

@p6rt
Copy link
Author

p6rt commented Mar 10, 2015

From @Mouq

On Tue May 06 02​:27​:58 2014, teodozjan wrote​:

Hi,

I found some hash issues on moar and parrot

sub y returns Array of Hash{
my %a1 = :x("y"), :y("z"), :w("c");
my %a2 =​:x("y"), :y("t"), :w("c");
my %a3 = :x("y"), :y("z"), :w("h");

my Hash $b1 = %a1;
my Hash $b2 = %a2;
my Hash $b3 = %a3;
say $b1.WHAT;
my Hash @​array = $b1,$b2,$b3;
}
y;
perl6 ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got
'Array[Hash]'
in any return_error at src/vm/moar/Perl6/Ops.nqp​:598
in sub y at /home/kamil/dev/sandbox/HashKing.pl​:27
in block at /home/kamil/dev/sandbox/HashKing.pl​:30

perl6-p ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed for return value; expected 'Array[Hash]' but got
'Array[Hash]'
in sub y at /home/kamil/dev/sandbox/HashKing.pl​:27
in block at /home/kamil/dev/sandbox/HashKing.pl​:30

This has been fixed in the most recent Rakudo; additionally, a test was added in Roast commit df6e66b70c7.

sub x returns Array of Hash{
my %a1 = :x("y"), :y("z"), :w("c");
my %a2 =​:x("y"), :y("t"), :w("c");
my %a3 = :x("y"), :y("z"), :w("h");
say %a1.WHAT;
my Hash @​array = %a1,%a2,%a3;
}
x;

$ perl6 ~/dev/sandbox/HashKing.pl
(Hash)
Type check failed in assignment to '@​array'; expected 'Hash' but got
'Pair'
in method REIFY at src/gen/m-CORE.setting​:8775
in method reify at src/gen/m-CORE.setting​:7611
in method gimme at src/gen/m-CORE.setting​:8049
in method sink at src/gen/m-CORE.setting​:8473
in method BUILDALL at src/gen/m-CORE.setting​:939
in method bless at src/gen/m-CORE.setting​:858
in method new at src/gen/m-CORE.setting​:843
in any return_error at src/vm/moar/Perl6/Ops.nqp​:598
in sub x at /home/kamil/dev/sandbox/HashKing.pl​:8
in block at /home/kamil/dev/sandbox/HashKing.pl​:15

The fact that this dies has to do with list assignment flattening its arguments (and Hashes flatten into their Pairs), so it's actually doing the right thing here :) I don't think these semantics are up for debate� on the other hand, if you think that the error is misleading or LTA, please open another report.

Otherwise, I'm marking this bug as resolved :)

@p6rt
Copy link
Author

p6rt commented Mar 10, 2015

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

@p6rt
Copy link
Author

p6rt commented Mar 10, 2015

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

@p6rt p6rt closed this as completed Mar 10, 2015
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant