Skip to content

Commit 30d991e

Browse files
committed
Fix nqp::setinvokespec on parrot. Add a test for it.
1 parent 0d19655 commit 30d991e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/vm/parrot/ops/nqp.ops

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,6 +2374,7 @@ inline op set_invocation_spec(invar PMC, invar PMC, in STR, invar PMC) :base_cor
23742374
InvocationSpec *new_spec = mem_allocate_zeroed_typed(InvocationSpec);
23752375
new_spec->value_slot.class_handle = $2;
23762376
new_spec->value_slot.attr_name = $3;
2377+
new_spec->value_slot.hint = NO_HINT;
23772378
new_spec->invocation_handler = $4;
23782379

23792380
/* Free any existing spec and put the new one in place. */

t/nqp/70-invokespec.t

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
plan(2);
2+
class Foo {
3+
has $!here_we_keep_the_code_ref;
4+
has $!other_place_we_could_keep_the_code_ref_in;
5+
method set_code_ref($code_ref) {
6+
$!here_we_keep_the_code_ref := $code_ref;
7+
}
8+
method set_code_ref_differently($code_ref) {
9+
$!other_place_we_could_keep_the_code_ref_in := $code_ref;
10+
}
11+
}
12+
class Bar is Foo {
13+
}
14+
nqp::setinvokespec(Foo,Foo,'$!here_we_keep_the_code_ref',nqp::null());
15+
16+
nqp::setinvokespec(Bar,Foo,'$!other_place_we_could_keep_the_code_ref_in',nqp::null());
17+
18+
my $foo := Foo.new();
19+
$foo.set_code_ref(sub() {123});
20+
$foo.set_code_ref_differently(sub() {456});
21+
ok($foo() == 123,"basic setinvokespec");
22+
23+
my $bar := Bar.new();
24+
$bar.set_code_ref(sub() {1001});
25+
$bar.set_code_ref_differently(sub() {1002});
26+
ok($bar() == 1002,"setinvokespec with a attribute in a subclass");
27+

0 commit comments

Comments
 (0)