Skip to content

Commit

Permalink
Add typechecking to binding attribute parameters
Browse files Browse the repository at this point in the history
Action #13 of the buildplan.  This was forgotten in the recent
addition of "is built(:bind).
  • Loading branch information
lizmat committed Feb 6, 2020
1 parent 22d5ffc commit 8920343
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/Perl6/World.nqp
Expand Up @@ -3613,12 +3613,16 @@ class Perl6::World is HLL::World {

# nqp::bindattr(self,Foo,'$!a',tmp)
elsif $code == 13 {
my $arg := QAST::Var.new( :name($tmp), :scope<local> );
if nqp::elems($task) == 5 {
$arg := QAST::Op.new(
:op('p6bindassert'),$arg,
QAST::WVal.new(:value(nqp::atpos($task,4)))
);
}
$if.push(
QAST::Op.new(
:op('bindattr'),
$self, $class, $attr,
QAST::Var.new( :name($tmp), :scope<local> )
)
:op('bindattr'),$self,$class,$attr,$arg)
);
}

Expand Down
18 changes: 16 additions & 2 deletions src/core.c/Mu.pm6
Expand Up @@ -324,7 +324,14 @@ Perhaps it can be found at https://docs.raku.org/type/$name"
nqp::existskey($init,nqp::atpos($task,3)),
nqp::bindattr(self,
nqp::atpos($task,1),nqp::atpos($task,2),
%attrinit.AT-KEY(nqp::atpos($task,3)))
nqp::if(
nqp::elems($task) == 5,
nqp::p6bindassert(
%attrinit.AT-KEY(nqp::atpos($task,3)),
nqp::atpos($task,4)),
%attrinit.AT-KEY(nqp::atpos($task,3))
)
)
),

nqp::if(
Expand Down Expand Up @@ -566,7 +573,14 @@ Perhaps it can be found at https://docs.raku.org/type/$name"
nqp::existskey($init,nqp::atpos($task,3)),
nqp::bindattr(self,
nqp::atpos($task,1),nqp::atpos($task,2),
%attrinit.AT-KEY(nqp::atpos($task,3))),
nqp::if(
nqp::elems($task) == 5,
nqp::p6bindassert(
%attrinit.AT-KEY(nqp::atpos($task,3)),
nqp::atpos($task,4)),
%attrinit.AT-KEY(nqp::atpos($task,3))
)
)
),

nqp::if(
Expand Down

0 comments on commit 8920343

Please sign in to comment.